
obj/user/testshell.debug:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 7d 04 00 00       	call   8004ae <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>

00800033 <wrong>:
	breakpoint();
}

void
wrong(int rfd, int kfd, int off)
{
  800033:	f3 0f 1e fb          	endbr32 
  800037:	55                   	push   %ebp
  800038:	89 e5                	mov    %esp,%ebp
  80003a:	57                   	push   %edi
  80003b:	56                   	push   %esi
  80003c:	53                   	push   %ebx
  80003d:	81 ec 84 00 00 00    	sub    $0x84,%esp
  800043:	8b 75 08             	mov    0x8(%ebp),%esi
  800046:	8b 7d 0c             	mov    0xc(%ebp),%edi
  800049:	8b 5d 10             	mov    0x10(%ebp),%ebx
	char buf[100];
	int n;

	seek(rfd, off);
  80004c:	53                   	push   %ebx
  80004d:	56                   	push   %esi
  80004e:	e8 85 19 00 00       	call   8019d8 <seek>
	seek(kfd, off);
  800053:	83 c4 08             	add    $0x8,%esp
  800056:	53                   	push   %ebx
  800057:	57                   	push   %edi
  800058:	e8 7b 19 00 00       	call   8019d8 <seek>

	cprintf("shell produced incorrect output.\n");
  80005d:	c7 04 24 e0 2b 80 00 	movl   $0x802be0,(%esp)
  800064:	e8 9e 05 00 00       	call   800607 <cprintf>
	cprintf("expected:\n===\n");
  800069:	c7 04 24 4b 2c 80 00 	movl   $0x802c4b,(%esp)
  800070:	e8 92 05 00 00       	call   800607 <cprintf>
	while ((n = read(kfd, buf, sizeof buf-1)) > 0)
  800075:	83 c4 10             	add    $0x10,%esp
  800078:	8d 5d 84             	lea    -0x7c(%ebp),%ebx
  80007b:	83 ec 04             	sub    $0x4,%esp
  80007e:	6a 63                	push   $0x63
  800080:	53                   	push   %ebx
  800081:	57                   	push   %edi
  800082:	e8 f5 17 00 00       	call   80187c <read>
  800087:	83 c4 10             	add    $0x10,%esp
  80008a:	85 c0                	test   %eax,%eax
  80008c:	7e 0f                	jle    80009d <wrong+0x6a>
		sys_cputs(buf, n);
  80008e:	83 ec 08             	sub    $0x8,%esp
  800091:	50                   	push   %eax
  800092:	53                   	push   %ebx
  800093:	e8 ba 0e 00 00       	call   800f52 <sys_cputs>
  800098:	83 c4 10             	add    $0x10,%esp
  80009b:	eb de                	jmp    80007b <wrong+0x48>
	cprintf("===\ngot:\n===\n");
  80009d:	83 ec 0c             	sub    $0xc,%esp
  8000a0:	68 5a 2c 80 00       	push   $0x802c5a
  8000a5:	e8 5d 05 00 00       	call   800607 <cprintf>
	while ((n = read(rfd, buf, sizeof buf-1)) > 0)
  8000aa:	83 c4 10             	add    $0x10,%esp
  8000ad:	8d 5d 84             	lea    -0x7c(%ebp),%ebx
  8000b0:	eb 0d                	jmp    8000bf <wrong+0x8c>
		sys_cputs(buf, n);
  8000b2:	83 ec 08             	sub    $0x8,%esp
  8000b5:	50                   	push   %eax
  8000b6:	53                   	push   %ebx
  8000b7:	e8 96 0e 00 00       	call   800f52 <sys_cputs>
  8000bc:	83 c4 10             	add    $0x10,%esp
	while ((n = read(rfd, buf, sizeof buf-1)) > 0)
  8000bf:	83 ec 04             	sub    $0x4,%esp
  8000c2:	6a 63                	push   $0x63
  8000c4:	53                   	push   %ebx
  8000c5:	56                   	push   %esi
  8000c6:	e8 b1 17 00 00       	call   80187c <read>
  8000cb:	83 c4 10             	add    $0x10,%esp
  8000ce:	85 c0                	test   %eax,%eax
  8000d0:	7f e0                	jg     8000b2 <wrong+0x7f>
	cprintf("===\n");
  8000d2:	83 ec 0c             	sub    $0xc,%esp
  8000d5:	68 55 2c 80 00       	push   $0x802c55
  8000da:	e8 28 05 00 00       	call   800607 <cprintf>
	exit();
  8000df:	e8 1e 04 00 00       	call   800502 <exit>
}
  8000e4:	83 c4 10             	add    $0x10,%esp
  8000e7:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8000ea:	5b                   	pop    %ebx
  8000eb:	5e                   	pop    %esi
  8000ec:	5f                   	pop    %edi
  8000ed:	5d                   	pop    %ebp
  8000ee:	c3                   	ret    

008000ef <umain>:
{
  8000ef:	f3 0f 1e fb          	endbr32 
  8000f3:	55                   	push   %ebp
  8000f4:	89 e5                	mov    %esp,%ebp
  8000f6:	57                   	push   %edi
  8000f7:	56                   	push   %esi
  8000f8:	53                   	push   %ebx
  8000f9:	83 ec 38             	sub    $0x38,%esp
	close(0);
  8000fc:	6a 00                	push   $0x0
  8000fe:	e8 2f 16 00 00       	call   801732 <close>
	close(1);
  800103:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  80010a:	e8 23 16 00 00       	call   801732 <close>
	opencons();
  80010f:	e8 44 03 00 00       	call   800458 <opencons>
	opencons();
  800114:	e8 3f 03 00 00       	call   800458 <opencons>
	if ((rfd = open("testshell.sh", O_RDONLY)) < 0)
  800119:	83 c4 08             	add    $0x8,%esp
  80011c:	6a 00                	push   $0x0
  80011e:	68 68 2c 80 00       	push   $0x802c68
  800123:	e8 e9 1b 00 00       	call   801d11 <open>
  800128:	89 c3                	mov    %eax,%ebx
  80012a:	83 c4 10             	add    $0x10,%esp
  80012d:	85 c0                	test   %eax,%eax
  80012f:	0f 88 e7 00 00 00    	js     80021c <umain+0x12d>
	if ((wfd = pipe(pfds)) < 0)
  800135:	83 ec 0c             	sub    $0xc,%esp
  800138:	8d 45 dc             	lea    -0x24(%ebp),%eax
  80013b:	50                   	push   %eax
  80013c:	e8 6a 24 00 00       	call   8025ab <pipe>
  800141:	83 c4 10             	add    $0x10,%esp
  800144:	85 c0                	test   %eax,%eax
  800146:	0f 88 e2 00 00 00    	js     80022e <umain+0x13f>
	wfd = pfds[1];
  80014c:	8b 75 e0             	mov    -0x20(%ebp),%esi
	cprintf("running sh -x < testshell.sh | cat\n");
  80014f:	83 ec 0c             	sub    $0xc,%esp
  800152:	68 04 2c 80 00       	push   $0x802c04
  800157:	e8 ab 04 00 00       	call   800607 <cprintf>
	if ((r = fork()) < 0)
  80015c:	e8 f8 11 00 00       	call   801359 <fork>
  800161:	83 c4 10             	add    $0x10,%esp
  800164:	85 c0                	test   %eax,%eax
  800166:	0f 88 d4 00 00 00    	js     800240 <umain+0x151>
	if (r == 0) {
  80016c:	75 6f                	jne    8001dd <umain+0xee>
		dup(rfd, 0);
  80016e:	83 ec 08             	sub    $0x8,%esp
  800171:	6a 00                	push   $0x0
  800173:	53                   	push   %ebx
  800174:	e8 13 16 00 00       	call   80178c <dup>
		dup(wfd, 1);
  800179:	83 c4 08             	add    $0x8,%esp
  80017c:	6a 01                	push   $0x1
  80017e:	56                   	push   %esi
  80017f:	e8 08 16 00 00       	call   80178c <dup>
		close(rfd);
  800184:	89 1c 24             	mov    %ebx,(%esp)
  800187:	e8 a6 15 00 00       	call   801732 <close>
		close(wfd);
  80018c:	89 34 24             	mov    %esi,(%esp)
  80018f:	e8 9e 15 00 00       	call   801732 <close>
		if ((r = spawnl("/sh", "sh", "-x", 0)) < 0)
  800194:	6a 00                	push   $0x0
  800196:	68 ae 2c 80 00       	push   $0x802cae
  80019b:	68 72 2c 80 00       	push   $0x802c72
  8001a0:	68 b1 2c 80 00       	push   $0x802cb1
  8001a5:	e8 6e 21 00 00       	call   802318 <spawnl>
  8001aa:	89 c7                	mov    %eax,%edi
  8001ac:	83 c4 20             	add    $0x20,%esp
  8001af:	85 c0                	test   %eax,%eax
  8001b1:	0f 88 9b 00 00 00    	js     800252 <umain+0x163>
		close(0);
  8001b7:	83 ec 0c             	sub    $0xc,%esp
  8001ba:	6a 00                	push   $0x0
  8001bc:	e8 71 15 00 00       	call   801732 <close>
		close(1);
  8001c1:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  8001c8:	e8 65 15 00 00       	call   801732 <close>
		wait(r);
  8001cd:	89 3c 24             	mov    %edi,(%esp)
  8001d0:	e8 5b 25 00 00       	call   802730 <wait>
		exit();
  8001d5:	e8 28 03 00 00       	call   800502 <exit>
  8001da:	83 c4 10             	add    $0x10,%esp
	close(rfd);
  8001dd:	83 ec 0c             	sub    $0xc,%esp
  8001e0:	53                   	push   %ebx
  8001e1:	e8 4c 15 00 00       	call   801732 <close>
	close(wfd);
  8001e6:	89 34 24             	mov    %esi,(%esp)
  8001e9:	e8 44 15 00 00       	call   801732 <close>
	rfd = pfds[0];
  8001ee:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8001f1:	89 45 d0             	mov    %eax,-0x30(%ebp)
	if ((kfd = open("testshell.key", O_RDONLY)) < 0)
  8001f4:	83 c4 08             	add    $0x8,%esp
  8001f7:	6a 00                	push   $0x0
  8001f9:	68 bf 2c 80 00       	push   $0x802cbf
  8001fe:	e8 0e 1b 00 00       	call   801d11 <open>
  800203:	89 45 d4             	mov    %eax,-0x2c(%ebp)
  800206:	83 c4 10             	add    $0x10,%esp
  800209:	85 c0                	test   %eax,%eax
  80020b:	78 57                	js     800264 <umain+0x175>
  80020d:	be 01 00 00 00       	mov    $0x1,%esi
	nloff = 0;
  800212:	bf 00 00 00 00       	mov    $0x0,%edi
  800217:	e9 9a 00 00 00       	jmp    8002b6 <umain+0x1c7>
		panic("open testshell.sh: %e", rfd);
  80021c:	50                   	push   %eax
  80021d:	68 75 2c 80 00       	push   $0x802c75
  800222:	6a 13                	push   $0x13
  800224:	68 8b 2c 80 00       	push   $0x802c8b
  800229:	e8 f2 02 00 00       	call   800520 <_panic>
		panic("pipe: %e", wfd);
  80022e:	50                   	push   %eax
  80022f:	68 9c 2c 80 00       	push   $0x802c9c
  800234:	6a 15                	push   $0x15
  800236:	68 8b 2c 80 00       	push   $0x802c8b
  80023b:	e8 e0 02 00 00       	call   800520 <_panic>
		panic("fork: %e", r);
  800240:	50                   	push   %eax
  800241:	68 a5 2c 80 00       	push   $0x802ca5
  800246:	6a 1a                	push   $0x1a
  800248:	68 8b 2c 80 00       	push   $0x802c8b
  80024d:	e8 ce 02 00 00       	call   800520 <_panic>
			panic("spawn: %e", r);
  800252:	50                   	push   %eax
  800253:	68 b5 2c 80 00       	push   $0x802cb5
  800258:	6a 21                	push   $0x21
  80025a:	68 8b 2c 80 00       	push   $0x802c8b
  80025f:	e8 bc 02 00 00       	call   800520 <_panic>
		panic("open testshell.key for reading: %e", kfd);
  800264:	50                   	push   %eax
  800265:	68 28 2c 80 00       	push   $0x802c28
  80026a:	6a 2c                	push   $0x2c
  80026c:	68 8b 2c 80 00       	push   $0x802c8b
  800271:	e8 aa 02 00 00       	call   800520 <_panic>
			panic("reading testshell.out: %e", n1);
  800276:	53                   	push   %ebx
  800277:	68 cd 2c 80 00       	push   $0x802ccd
  80027c:	6a 33                	push   $0x33
  80027e:	68 8b 2c 80 00       	push   $0x802c8b
  800283:	e8 98 02 00 00       	call   800520 <_panic>
			panic("reading testshell.key: %e", n2);
  800288:	50                   	push   %eax
  800289:	68 e7 2c 80 00       	push   $0x802ce7
  80028e:	6a 35                	push   $0x35
  800290:	68 8b 2c 80 00       	push   $0x802c8b
  800295:	e8 86 02 00 00       	call   800520 <_panic>
			wrong(rfd, kfd, nloff);
  80029a:	83 ec 04             	sub    $0x4,%esp
  80029d:	57                   	push   %edi
  80029e:	ff 75 d4             	pushl  -0x2c(%ebp)
  8002a1:	ff 75 d0             	pushl  -0x30(%ebp)
  8002a4:	e8 8a fd ff ff       	call   800033 <wrong>
  8002a9:	83 c4 10             	add    $0x10,%esp
			nloff = off+1;
  8002ac:	80 7d e7 0a          	cmpb   $0xa,-0x19(%ebp)
  8002b0:	0f 44 fe             	cmove  %esi,%edi
  8002b3:	83 c6 01             	add    $0x1,%esi
		n1 = read(rfd, &c1, 1);
  8002b6:	83 ec 04             	sub    $0x4,%esp
  8002b9:	6a 01                	push   $0x1
  8002bb:	8d 45 e7             	lea    -0x19(%ebp),%eax
  8002be:	50                   	push   %eax
  8002bf:	ff 75 d0             	pushl  -0x30(%ebp)
  8002c2:	e8 b5 15 00 00       	call   80187c <read>
  8002c7:	89 c3                	mov    %eax,%ebx
		n2 = read(kfd, &c2, 1);
  8002c9:	83 c4 0c             	add    $0xc,%esp
  8002cc:	6a 01                	push   $0x1
  8002ce:	8d 45 e6             	lea    -0x1a(%ebp),%eax
  8002d1:	50                   	push   %eax
  8002d2:	ff 75 d4             	pushl  -0x2c(%ebp)
  8002d5:	e8 a2 15 00 00       	call   80187c <read>
		if (n1 < 0)
  8002da:	83 c4 10             	add    $0x10,%esp
  8002dd:	85 db                	test   %ebx,%ebx
  8002df:	78 95                	js     800276 <umain+0x187>
		if (n2 < 0)
  8002e1:	85 c0                	test   %eax,%eax
  8002e3:	78 a3                	js     800288 <umain+0x199>
		if (n1 == 0 && n2 == 0)
  8002e5:	89 da                	mov    %ebx,%edx
  8002e7:	09 c2                	or     %eax,%edx
  8002e9:	74 15                	je     800300 <umain+0x211>
		if (n1 != 1 || n2 != 1 || c1 != c2)
  8002eb:	83 fb 01             	cmp    $0x1,%ebx
  8002ee:	75 aa                	jne    80029a <umain+0x1ab>
  8002f0:	83 f8 01             	cmp    $0x1,%eax
  8002f3:	75 a5                	jne    80029a <umain+0x1ab>
  8002f5:	0f b6 45 e6          	movzbl -0x1a(%ebp),%eax
  8002f9:	38 45 e7             	cmp    %al,-0x19(%ebp)
  8002fc:	75 9c                	jne    80029a <umain+0x1ab>
  8002fe:	eb ac                	jmp    8002ac <umain+0x1bd>
	cprintf("shell ran correctly\n");
  800300:	83 ec 0c             	sub    $0xc,%esp
  800303:	68 01 2d 80 00       	push   $0x802d01
  800308:	e8 fa 02 00 00       	call   800607 <cprintf>
#include <inc/types.h>

static inline void
breakpoint(void)
{
	asm volatile("int3");
  80030d:	cc                   	int3   
}
  80030e:	83 c4 10             	add    $0x10,%esp
  800311:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800314:	5b                   	pop    %ebx
  800315:	5e                   	pop    %esi
  800316:	5f                   	pop    %edi
  800317:	5d                   	pop    %ebp
  800318:	c3                   	ret    

00800319 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  800319:	f3 0f 1e fb          	endbr32 
	USED(fd);

	return 0;
}
  80031d:	b8 00 00 00 00       	mov    $0x0,%eax
  800322:	c3                   	ret    

00800323 <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  800323:	f3 0f 1e fb          	endbr32 
  800327:	55                   	push   %ebp
  800328:	89 e5                	mov    %esp,%ebp
  80032a:	83 ec 10             	sub    $0x10,%esp
	strcpy(stat->st_name, "<cons>");
  80032d:	68 16 2d 80 00       	push   $0x802d16
  800332:	ff 75 0c             	pushl  0xc(%ebp)
  800335:	e8 a6 08 00 00       	call   800be0 <strcpy>
	return 0;
}
  80033a:	b8 00 00 00 00       	mov    $0x0,%eax
  80033f:	c9                   	leave  
  800340:	c3                   	ret    

00800341 <devcons_write>:
{
  800341:	f3 0f 1e fb          	endbr32 
  800345:	55                   	push   %ebp
  800346:	89 e5                	mov    %esp,%ebp
  800348:	57                   	push   %edi
  800349:	56                   	push   %esi
  80034a:	53                   	push   %ebx
  80034b:	81 ec 8c 00 00 00    	sub    $0x8c,%esp
	for (tot = 0; tot < n; tot += m) {
  800351:	be 00 00 00 00       	mov    $0x0,%esi
		memmove(buf, (char*)vbuf + tot, m);
  800356:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	for (tot = 0; tot < n; tot += m) {
  80035c:	3b 75 10             	cmp    0x10(%ebp),%esi
  80035f:	73 31                	jae    800392 <devcons_write+0x51>
		m = n - tot;
  800361:	8b 5d 10             	mov    0x10(%ebp),%ebx
  800364:	29 f3                	sub    %esi,%ebx
  800366:	83 fb 7f             	cmp    $0x7f,%ebx
  800369:	b8 7f 00 00 00       	mov    $0x7f,%eax
  80036e:	0f 47 d8             	cmova  %eax,%ebx
		memmove(buf, (char*)vbuf + tot, m);
  800371:	83 ec 04             	sub    $0x4,%esp
  800374:	53                   	push   %ebx
  800375:	89 f0                	mov    %esi,%eax
  800377:	03 45 0c             	add    0xc(%ebp),%eax
  80037a:	50                   	push   %eax
  80037b:	57                   	push   %edi
  80037c:	e8 15 0a 00 00       	call   800d96 <memmove>
		sys_cputs(buf, m);
  800381:	83 c4 08             	add    $0x8,%esp
  800384:	53                   	push   %ebx
  800385:	57                   	push   %edi
  800386:	e8 c7 0b 00 00       	call   800f52 <sys_cputs>
	for (tot = 0; tot < n; tot += m) {
  80038b:	01 de                	add    %ebx,%esi
  80038d:	83 c4 10             	add    $0x10,%esp
  800390:	eb ca                	jmp    80035c <devcons_write+0x1b>
}
  800392:	89 f0                	mov    %esi,%eax
  800394:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800397:	5b                   	pop    %ebx
  800398:	5e                   	pop    %esi
  800399:	5f                   	pop    %edi
  80039a:	5d                   	pop    %ebp
  80039b:	c3                   	ret    

0080039c <devcons_read>:
{
  80039c:	f3 0f 1e fb          	endbr32 
  8003a0:	55                   	push   %ebp
  8003a1:	89 e5                	mov    %esp,%ebp
  8003a3:	83 ec 08             	sub    $0x8,%esp
  8003a6:	b8 00 00 00 00       	mov    $0x0,%eax
	if (n == 0)
  8003ab:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  8003af:	74 21                	je     8003d2 <devcons_read+0x36>
	while ((c = sys_cgetc()) == 0)
  8003b1:	e8 be 0b 00 00       	call   800f74 <sys_cgetc>
  8003b6:	85 c0                	test   %eax,%eax
  8003b8:	75 07                	jne    8003c1 <devcons_read+0x25>
		sys_yield();
  8003ba:	e8 40 0c 00 00       	call   800fff <sys_yield>
  8003bf:	eb f0                	jmp    8003b1 <devcons_read+0x15>
	if (c < 0)
  8003c1:	78 0f                	js     8003d2 <devcons_read+0x36>
	if (c == 0x04)	// ctl-d is eof
  8003c3:	83 f8 04             	cmp    $0x4,%eax
  8003c6:	74 0c                	je     8003d4 <devcons_read+0x38>
	*(char*)vbuf = c;
  8003c8:	8b 55 0c             	mov    0xc(%ebp),%edx
  8003cb:	88 02                	mov    %al,(%edx)
	return 1;
  8003cd:	b8 01 00 00 00       	mov    $0x1,%eax
}
  8003d2:	c9                   	leave  
  8003d3:	c3                   	ret    
		return 0;
  8003d4:	b8 00 00 00 00       	mov    $0x0,%eax
  8003d9:	eb f7                	jmp    8003d2 <devcons_read+0x36>

008003db <cputchar>:
{
  8003db:	f3 0f 1e fb          	endbr32 
  8003df:	55                   	push   %ebp
  8003e0:	89 e5                	mov    %esp,%ebp
  8003e2:	83 ec 20             	sub    $0x20,%esp
	char c = ch;
  8003e5:	8b 45 08             	mov    0x8(%ebp),%eax
  8003e8:	88 45 f7             	mov    %al,-0x9(%ebp)
	sys_cputs(&c, 1);
  8003eb:	6a 01                	push   $0x1
  8003ed:	8d 45 f7             	lea    -0x9(%ebp),%eax
  8003f0:	50                   	push   %eax
  8003f1:	e8 5c 0b 00 00       	call   800f52 <sys_cputs>
}
  8003f6:	83 c4 10             	add    $0x10,%esp
  8003f9:	c9                   	leave  
  8003fa:	c3                   	ret    

008003fb <getchar>:
{
  8003fb:	f3 0f 1e fb          	endbr32 
  8003ff:	55                   	push   %ebp
  800400:	89 e5                	mov    %esp,%ebp
  800402:	83 ec 1c             	sub    $0x1c,%esp
	r = read(0, &c, 1);
  800405:	6a 01                	push   $0x1
  800407:	8d 45 f7             	lea    -0x9(%ebp),%eax
  80040a:	50                   	push   %eax
  80040b:	6a 00                	push   $0x0
  80040d:	e8 6a 14 00 00       	call   80187c <read>
	if (r < 0)
  800412:	83 c4 10             	add    $0x10,%esp
  800415:	85 c0                	test   %eax,%eax
  800417:	78 06                	js     80041f <getchar+0x24>
	if (r < 1)
  800419:	74 06                	je     800421 <getchar+0x26>
	return c;
  80041b:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  80041f:	c9                   	leave  
  800420:	c3                   	ret    
		return -E_EOF;
  800421:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  800426:	eb f7                	jmp    80041f <getchar+0x24>

00800428 <iscons>:
{
  800428:	f3 0f 1e fb          	endbr32 
  80042c:	55                   	push   %ebp
  80042d:	89 e5                	mov    %esp,%ebp
  80042f:	83 ec 20             	sub    $0x20,%esp
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  800432:	8d 45 f4             	lea    -0xc(%ebp),%eax
  800435:	50                   	push   %eax
  800436:	ff 75 08             	pushl  0x8(%ebp)
  800439:	e8 bb 11 00 00       	call   8015f9 <fd_lookup>
  80043e:	83 c4 10             	add    $0x10,%esp
  800441:	85 c0                	test   %eax,%eax
  800443:	78 11                	js     800456 <iscons+0x2e>
	return fd->fd_dev_id == devcons.dev_id;
  800445:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800448:	8b 15 00 40 80 00    	mov    0x804000,%edx
  80044e:	39 10                	cmp    %edx,(%eax)
  800450:	0f 94 c0             	sete   %al
  800453:	0f b6 c0             	movzbl %al,%eax
}
  800456:	c9                   	leave  
  800457:	c3                   	ret    

00800458 <opencons>:
{
  800458:	f3 0f 1e fb          	endbr32 
  80045c:	55                   	push   %ebp
  80045d:	89 e5                	mov    %esp,%ebp
  80045f:	83 ec 24             	sub    $0x24,%esp
	if ((r = fd_alloc(&fd)) < 0)
  800462:	8d 45 f4             	lea    -0xc(%ebp),%eax
  800465:	50                   	push   %eax
  800466:	e8 38 11 00 00       	call   8015a3 <fd_alloc>
  80046b:	83 c4 10             	add    $0x10,%esp
  80046e:	85 c0                	test   %eax,%eax
  800470:	78 3a                	js     8004ac <opencons+0x54>
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  800472:	83 ec 04             	sub    $0x4,%esp
  800475:	68 07 04 00 00       	push   $0x407
  80047a:	ff 75 f4             	pushl  -0xc(%ebp)
  80047d:	6a 00                	push   $0x0
  80047f:	e8 9e 0b 00 00       	call   801022 <sys_page_alloc>
  800484:	83 c4 10             	add    $0x10,%esp
  800487:	85 c0                	test   %eax,%eax
  800489:	78 21                	js     8004ac <opencons+0x54>
	fd->fd_dev_id = devcons.dev_id;
  80048b:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80048e:	8b 15 00 40 80 00    	mov    0x804000,%edx
  800494:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  800496:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800499:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  8004a0:	83 ec 0c             	sub    $0xc,%esp
  8004a3:	50                   	push   %eax
  8004a4:	e8 cb 10 00 00       	call   801574 <fd2num>
  8004a9:	83 c4 10             	add    $0x10,%esp
}
  8004ac:	c9                   	leave  
  8004ad:	c3                   	ret    

008004ae <libmain>:
const volatile struct Env *thisenv;
const char *binaryname = "<unknown>";

void
libmain(int argc, char **argv)
{
  8004ae:	f3 0f 1e fb          	endbr32 
  8004b2:	55                   	push   %ebp
  8004b3:	89 e5                	mov    %esp,%ebp
  8004b5:	56                   	push   %esi
  8004b6:	53                   	push   %ebx
  8004b7:	8b 5d 08             	mov    0x8(%ebp),%ebx
  8004ba:	8b 75 0c             	mov    0xc(%ebp),%esi
	;    //系统调用，我们已经在Exercise 7中实现了
	
	
	
	//屏幕上打印出来了字母，但后续报错了，有意思，让我看看问题出现在哪。
	thisenv=0;
  8004bd:	c7 05 04 50 80 00 00 	movl   $0x0,0x805004
  8004c4:	00 00 00 
	thisenv = &envs[ENVX(sys_getenvid())];      //获取Env结构指针
  8004c7:	e8 10 0b 00 00       	call   800fdc <sys_getenvid>
  8004cc:	25 ff 03 00 00       	and    $0x3ff,%eax
  8004d1:	6b c0 7c             	imul   $0x7c,%eax,%eax
  8004d4:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  8004d9:	a3 04 50 80 00       	mov    %eax,0x805004

	// save the name of the program so that panic() can use it
	if (argc > 0)
  8004de:	85 db                	test   %ebx,%ebx
  8004e0:	7e 07                	jle    8004e9 <libmain+0x3b>
		binaryname = argv[0];
  8004e2:	8b 06                	mov    (%esi),%eax
  8004e4:	a3 1c 40 80 00       	mov    %eax,0x80401c

	// call user main routine
	umain(argc, argv);
  8004e9:	83 ec 08             	sub    $0x8,%esp
  8004ec:	56                   	push   %esi
  8004ed:	53                   	push   %ebx
  8004ee:	e8 fc fb ff ff       	call   8000ef <umain>

	// exit gracefully
	exit();
  8004f3:	e8 0a 00 00 00       	call   800502 <exit>
}
  8004f8:	83 c4 10             	add    $0x10,%esp
  8004fb:	8d 65 f8             	lea    -0x8(%ebp),%esp
  8004fe:	5b                   	pop    %ebx
  8004ff:	5e                   	pop    %esi
  800500:	5d                   	pop    %ebp
  800501:	c3                   	ret    

00800502 <exit>:

#include <inc/lib.h>

void
exit(void)
{
  800502:	f3 0f 1e fb          	endbr32 
  800506:	55                   	push   %ebp
  800507:	89 e5                	mov    %esp,%ebp
  800509:	83 ec 08             	sub    $0x8,%esp
	close_all();
  80050c:	e8 52 12 00 00       	call   801763 <close_all>
	sys_env_destroy(0);
  800511:	83 ec 0c             	sub    $0xc,%esp
  800514:	6a 00                	push   $0x0
  800516:	e8 7c 0a 00 00       	call   800f97 <sys_env_destroy>
}
  80051b:	83 c4 10             	add    $0x10,%esp
  80051e:	c9                   	leave  
  80051f:	c3                   	ret    

00800520 <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt, ...)
{
  800520:	f3 0f 1e fb          	endbr32 
  800524:	55                   	push   %ebp
  800525:	89 e5                	mov    %esp,%ebp
  800527:	56                   	push   %esi
  800528:	53                   	push   %ebx
	va_list ap;

	va_start(ap, fmt);
  800529:	8d 5d 14             	lea    0x14(%ebp),%ebx

	// Print the panic message
	cprintf("[%08x] user panic in %s at %s:%d: ",
  80052c:	8b 35 1c 40 80 00    	mov    0x80401c,%esi
  800532:	e8 a5 0a 00 00       	call   800fdc <sys_getenvid>
  800537:	83 ec 0c             	sub    $0xc,%esp
  80053a:	ff 75 0c             	pushl  0xc(%ebp)
  80053d:	ff 75 08             	pushl  0x8(%ebp)
  800540:	56                   	push   %esi
  800541:	50                   	push   %eax
  800542:	68 2c 2d 80 00       	push   $0x802d2c
  800547:	e8 bb 00 00 00       	call   800607 <cprintf>
		sys_getenvid(), binaryname, file, line);
	vcprintf(fmt, ap);
  80054c:	83 c4 18             	add    $0x18,%esp
  80054f:	53                   	push   %ebx
  800550:	ff 75 10             	pushl  0x10(%ebp)
  800553:	e8 5a 00 00 00       	call   8005b2 <vcprintf>
	cprintf("\n");
  800558:	c7 04 24 58 2c 80 00 	movl   $0x802c58,(%esp)
  80055f:	e8 a3 00 00 00       	call   800607 <cprintf>
  800564:	83 c4 10             	add    $0x10,%esp

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  800567:	cc                   	int3   
  800568:	eb fd                	jmp    800567 <_panic+0x47>

0080056a <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  80056a:	f3 0f 1e fb          	endbr32 
  80056e:	55                   	push   %ebp
  80056f:	89 e5                	mov    %esp,%ebp
  800571:	53                   	push   %ebx
  800572:	83 ec 04             	sub    $0x4,%esp
  800575:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  800578:	8b 13                	mov    (%ebx),%edx
  80057a:	8d 42 01             	lea    0x1(%edx),%eax
  80057d:	89 03                	mov    %eax,(%ebx)
  80057f:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800582:	88 4c 13 08          	mov    %cl,0x8(%ebx,%edx,1)
	if (b->idx == 256-1) {
  800586:	3d ff 00 00 00       	cmp    $0xff,%eax
  80058b:	74 09                	je     800596 <putch+0x2c>
		sys_cputs(b->buf, b->idx);
		b->idx = 0;
	}
	b->cnt++;
  80058d:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  800591:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  800594:	c9                   	leave  
  800595:	c3                   	ret    
		sys_cputs(b->buf, b->idx);
  800596:	83 ec 08             	sub    $0x8,%esp
  800599:	68 ff 00 00 00       	push   $0xff
  80059e:	8d 43 08             	lea    0x8(%ebx),%eax
  8005a1:	50                   	push   %eax
  8005a2:	e8 ab 09 00 00       	call   800f52 <sys_cputs>
		b->idx = 0;
  8005a7:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  8005ad:	83 c4 10             	add    $0x10,%esp
  8005b0:	eb db                	jmp    80058d <putch+0x23>

008005b2 <vcprintf>:

int
vcprintf(const char *fmt, va_list ap)
{
  8005b2:	f3 0f 1e fb          	endbr32 
  8005b6:	55                   	push   %ebp
  8005b7:	89 e5                	mov    %esp,%ebp
  8005b9:	81 ec 18 01 00 00    	sub    $0x118,%esp
	struct printbuf b;

	b.idx = 0;
  8005bf:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  8005c6:	00 00 00 
	b.cnt = 0;
  8005c9:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  8005d0:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  8005d3:	ff 75 0c             	pushl  0xc(%ebp)
  8005d6:	ff 75 08             	pushl  0x8(%ebp)
  8005d9:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  8005df:	50                   	push   %eax
  8005e0:	68 6a 05 80 00       	push   $0x80056a
  8005e5:	e8 20 01 00 00       	call   80070a <vprintfmt>
	sys_cputs(b.buf, b.idx);
  8005ea:	83 c4 08             	add    $0x8,%esp
  8005ed:	ff b5 f0 fe ff ff    	pushl  -0x110(%ebp)
  8005f3:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  8005f9:	50                   	push   %eax
  8005fa:	e8 53 09 00 00       	call   800f52 <sys_cputs>

	return b.cnt;
}
  8005ff:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  800605:	c9                   	leave  
  800606:	c3                   	ret    

00800607 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  800607:	f3 0f 1e fb          	endbr32 
  80060b:	55                   	push   %ebp
  80060c:	89 e5                	mov    %esp,%ebp
  80060e:	83 ec 10             	sub    $0x10,%esp
	va_list ap;
	int cnt;

	va_start(ap, fmt);
  800611:	8d 45 0c             	lea    0xc(%ebp),%eax
	cnt = vcprintf(fmt, ap);
  800614:	50                   	push   %eax
  800615:	ff 75 08             	pushl  0x8(%ebp)
  800618:	e8 95 ff ff ff       	call   8005b2 <vcprintf>
	va_end(ap);

	return cnt;
}
  80061d:	c9                   	leave  
  80061e:	c3                   	ret    

0080061f <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  80061f:	55                   	push   %ebp
  800620:	89 e5                	mov    %esp,%ebp
  800622:	57                   	push   %edi
  800623:	56                   	push   %esi
  800624:	53                   	push   %ebx
  800625:	83 ec 1c             	sub    $0x1c,%esp
  800628:	89 c7                	mov    %eax,%edi
  80062a:	89 d6                	mov    %edx,%esi
  80062c:	8b 45 08             	mov    0x8(%ebp),%eax
  80062f:	8b 55 0c             	mov    0xc(%ebp),%edx
  800632:	89 d1                	mov    %edx,%ecx
  800634:	89 c2                	mov    %eax,%edx
  800636:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800639:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  80063c:	8b 45 10             	mov    0x10(%ebp),%eax
  80063f:	8b 5d 14             	mov    0x14(%ebp),%ebx
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  800642:	89 45 e0             	mov    %eax,-0x20(%ebp)
  800645:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  80064c:	39 c2                	cmp    %eax,%edx
  80064e:	1b 4d e4             	sbb    -0x1c(%ebp),%ecx
  800651:	72 3e                	jb     800691 <printnum+0x72>
		printnum(putch, putdat, num / base, base, width - 1, padc);
  800653:	83 ec 0c             	sub    $0xc,%esp
  800656:	ff 75 18             	pushl  0x18(%ebp)
  800659:	83 eb 01             	sub    $0x1,%ebx
  80065c:	53                   	push   %ebx
  80065d:	50                   	push   %eax
  80065e:	83 ec 08             	sub    $0x8,%esp
  800661:	ff 75 e4             	pushl  -0x1c(%ebp)
  800664:	ff 75 e0             	pushl  -0x20(%ebp)
  800667:	ff 75 dc             	pushl  -0x24(%ebp)
  80066a:	ff 75 d8             	pushl  -0x28(%ebp)
  80066d:	e8 0e 23 00 00       	call   802980 <__udivdi3>
  800672:	83 c4 18             	add    $0x18,%esp
  800675:	52                   	push   %edx
  800676:	50                   	push   %eax
  800677:	89 f2                	mov    %esi,%edx
  800679:	89 f8                	mov    %edi,%eax
  80067b:	e8 9f ff ff ff       	call   80061f <printnum>
  800680:	83 c4 20             	add    $0x20,%esp
  800683:	eb 13                	jmp    800698 <printnum+0x79>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  800685:	83 ec 08             	sub    $0x8,%esp
  800688:	56                   	push   %esi
  800689:	ff 75 18             	pushl  0x18(%ebp)
  80068c:	ff d7                	call   *%edi
  80068e:	83 c4 10             	add    $0x10,%esp
		while (--width > 0)
  800691:	83 eb 01             	sub    $0x1,%ebx
  800694:	85 db                	test   %ebx,%ebx
  800696:	7f ed                	jg     800685 <printnum+0x66>
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  800698:	83 ec 08             	sub    $0x8,%esp
  80069b:	56                   	push   %esi
  80069c:	83 ec 04             	sub    $0x4,%esp
  80069f:	ff 75 e4             	pushl  -0x1c(%ebp)
  8006a2:	ff 75 e0             	pushl  -0x20(%ebp)
  8006a5:	ff 75 dc             	pushl  -0x24(%ebp)
  8006a8:	ff 75 d8             	pushl  -0x28(%ebp)
  8006ab:	e8 e0 23 00 00       	call   802a90 <__umoddi3>
  8006b0:	83 c4 14             	add    $0x14,%esp
  8006b3:	0f be 80 4f 2d 80 00 	movsbl 0x802d4f(%eax),%eax
  8006ba:	50                   	push   %eax
  8006bb:	ff d7                	call   *%edi
}
  8006bd:	83 c4 10             	add    $0x10,%esp
  8006c0:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8006c3:	5b                   	pop    %ebx
  8006c4:	5e                   	pop    %esi
  8006c5:	5f                   	pop    %edi
  8006c6:	5d                   	pop    %ebp
  8006c7:	c3                   	ret    

008006c8 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  8006c8:	f3 0f 1e fb          	endbr32 
  8006cc:	55                   	push   %ebp
  8006cd:	89 e5                	mov    %esp,%ebp
  8006cf:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  8006d2:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  8006d6:	8b 10                	mov    (%eax),%edx
  8006d8:	3b 50 04             	cmp    0x4(%eax),%edx
  8006db:	73 0a                	jae    8006e7 <sprintputch+0x1f>
		*b->buf++ = ch;
  8006dd:	8d 4a 01             	lea    0x1(%edx),%ecx
  8006e0:	89 08                	mov    %ecx,(%eax)
  8006e2:	8b 45 08             	mov    0x8(%ebp),%eax
  8006e5:	88 02                	mov    %al,(%edx)
}
  8006e7:	5d                   	pop    %ebp
  8006e8:	c3                   	ret    

008006e9 <printfmt>:
{
  8006e9:	f3 0f 1e fb          	endbr32 
  8006ed:	55                   	push   %ebp
  8006ee:	89 e5                	mov    %esp,%ebp
  8006f0:	83 ec 08             	sub    $0x8,%esp
	va_start(ap, fmt);
  8006f3:	8d 45 14             	lea    0x14(%ebp),%eax
	vprintfmt(putch, putdat, fmt, ap);
  8006f6:	50                   	push   %eax
  8006f7:	ff 75 10             	pushl  0x10(%ebp)
  8006fa:	ff 75 0c             	pushl  0xc(%ebp)
  8006fd:	ff 75 08             	pushl  0x8(%ebp)
  800700:	e8 05 00 00 00       	call   80070a <vprintfmt>
}
  800705:	83 c4 10             	add    $0x10,%esp
  800708:	c9                   	leave  
  800709:	c3                   	ret    

0080070a <vprintfmt>:
{
  80070a:	f3 0f 1e fb          	endbr32 
  80070e:	55                   	push   %ebp
  80070f:	89 e5                	mov    %esp,%ebp
  800711:	57                   	push   %edi
  800712:	56                   	push   %esi
  800713:	53                   	push   %ebx
  800714:	83 ec 3c             	sub    $0x3c,%esp
  800717:	8b 75 08             	mov    0x8(%ebp),%esi
  80071a:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  80071d:	8b 7d 10             	mov    0x10(%ebp),%edi
  800720:	e9 5d 03 00 00       	jmp    800a82 <vprintfmt+0x378>
		padc = ' ';
  800725:	c6 45 d3 20          	movb   $0x20,-0x2d(%ebp)
		altflag = 0;
  800729:	c7 45 e0 00 00 00 00 	movl   $0x0,-0x20(%ebp)
		precision = -1;
  800730:	c7 45 d8 ff ff ff ff 	movl   $0xffffffff,-0x28(%ebp)
		width = -1;
  800737:	c7 45 d4 ff ff ff ff 	movl   $0xffffffff,-0x2c(%ebp)
		lflag = 0;
  80073e:	b9 00 00 00 00       	mov    $0x0,%ecx
		switch (ch = *(unsigned char *) fmt++) {
  800743:	8d 47 01             	lea    0x1(%edi),%eax
  800746:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  800749:	0f b6 17             	movzbl (%edi),%edx
  80074c:	8d 42 dd             	lea    -0x23(%edx),%eax
  80074f:	3c 55                	cmp    $0x55,%al
  800751:	0f 87 ae 03 00 00    	ja     800b05 <vprintfmt+0x3fb>
  800757:	0f b6 c0             	movzbl %al,%eax
  80075a:	3e ff 24 85 a0 2e 80 	notrack jmp *0x802ea0(,%eax,4)
  800761:	00 
  800762:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			padc = '-';
  800765:	c6 45 d3 2d          	movb   $0x2d,-0x2d(%ebp)
  800769:	eb d8                	jmp    800743 <vprintfmt+0x39>
		switch (ch = *(unsigned char *) fmt++) {
  80076b:	8b 7d e4             	mov    -0x1c(%ebp),%edi
  80076e:	c6 45 d3 30          	movb   $0x30,-0x2d(%ebp)
  800772:	eb cf                	jmp    800743 <vprintfmt+0x39>
  800774:	0f b6 d2             	movzbl %dl,%edx
  800777:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			for (precision = 0; ; ++fmt) {
  80077a:	b8 00 00 00 00       	mov    $0x0,%eax
  80077f:	89 4d e4             	mov    %ecx,-0x1c(%ebp)
				precision = precision * 10 + ch - '0';
  800782:	8d 04 80             	lea    (%eax,%eax,4),%eax
  800785:	8d 44 42 d0          	lea    -0x30(%edx,%eax,2),%eax
				ch = *fmt;
  800789:	0f be 17             	movsbl (%edi),%edx
				if (ch < '0' || ch > '9')
  80078c:	8d 4a d0             	lea    -0x30(%edx),%ecx
  80078f:	83 f9 09             	cmp    $0x9,%ecx
  800792:	77 55                	ja     8007e9 <vprintfmt+0xdf>
			for (precision = 0; ; ++fmt) {
  800794:	83 c7 01             	add    $0x1,%edi
				precision = precision * 10 + ch - '0';
  800797:	eb e9                	jmp    800782 <vprintfmt+0x78>
			precision = va_arg(ap, int);
  800799:	8b 45 14             	mov    0x14(%ebp),%eax
  80079c:	8b 00                	mov    (%eax),%eax
  80079e:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8007a1:	8b 45 14             	mov    0x14(%ebp),%eax
  8007a4:	8d 40 04             	lea    0x4(%eax),%eax
  8007a7:	89 45 14             	mov    %eax,0x14(%ebp)
		switch (ch = *(unsigned char *) fmt++) {
  8007aa:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			if (width < 0)
  8007ad:	83 7d d4 00          	cmpl   $0x0,-0x2c(%ebp)
  8007b1:	79 90                	jns    800743 <vprintfmt+0x39>
				width = precision, precision = -1;
  8007b3:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8007b6:	89 45 d4             	mov    %eax,-0x2c(%ebp)
  8007b9:	c7 45 d8 ff ff ff ff 	movl   $0xffffffff,-0x28(%ebp)
  8007c0:	eb 81                	jmp    800743 <vprintfmt+0x39>
  8007c2:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  8007c5:	85 c0                	test   %eax,%eax
  8007c7:	ba 00 00 00 00       	mov    $0x0,%edx
  8007cc:	0f 49 d0             	cmovns %eax,%edx
  8007cf:	89 55 d4             	mov    %edx,-0x2c(%ebp)
		switch (ch = *(unsigned char *) fmt++) {
  8007d2:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			goto reswitch;
  8007d5:	e9 69 ff ff ff       	jmp    800743 <vprintfmt+0x39>
		switch (ch = *(unsigned char *) fmt++) {
  8007da:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			altflag = 1;
  8007dd:	c7 45 e0 01 00 00 00 	movl   $0x1,-0x20(%ebp)
			goto reswitch;
  8007e4:	e9 5a ff ff ff       	jmp    800743 <vprintfmt+0x39>
  8007e9:	8b 4d e4             	mov    -0x1c(%ebp),%ecx
  8007ec:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8007ef:	eb bc                	jmp    8007ad <vprintfmt+0xa3>
			lflag++;
  8007f1:	83 c1 01             	add    $0x1,%ecx
		switch (ch = *(unsigned char *) fmt++) {
  8007f4:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			goto reswitch;
  8007f7:	e9 47 ff ff ff       	jmp    800743 <vprintfmt+0x39>
			putch(va_arg(ap, int), putdat);
  8007fc:	8b 45 14             	mov    0x14(%ebp),%eax
  8007ff:	8d 78 04             	lea    0x4(%eax),%edi
  800802:	83 ec 08             	sub    $0x8,%esp
  800805:	53                   	push   %ebx
  800806:	ff 30                	pushl  (%eax)
  800808:	ff d6                	call   *%esi
			break;
  80080a:	83 c4 10             	add    $0x10,%esp
			putch(va_arg(ap, int), putdat);
  80080d:	89 7d 14             	mov    %edi,0x14(%ebp)
			break;
  800810:	e9 6a 02 00 00       	jmp    800a7f <vprintfmt+0x375>
			err = va_arg(ap, int);
  800815:	8b 45 14             	mov    0x14(%ebp),%eax
  800818:	8d 78 04             	lea    0x4(%eax),%edi
  80081b:	8b 00                	mov    (%eax),%eax
  80081d:	99                   	cltd   
  80081e:	31 d0                	xor    %edx,%eax
  800820:	29 d0                	sub    %edx,%eax
			if (err >= MAXERROR || (p = error_string[err]) == NULL)
  800822:	83 f8 0f             	cmp    $0xf,%eax
  800825:	7f 23                	jg     80084a <vprintfmt+0x140>
  800827:	8b 14 85 00 30 80 00 	mov    0x803000(,%eax,4),%edx
  80082e:	85 d2                	test   %edx,%edx
  800830:	74 18                	je     80084a <vprintfmt+0x140>
				printfmt(putch, putdat, "%s", p);
  800832:	52                   	push   %edx
  800833:	68 81 32 80 00       	push   $0x803281
  800838:	53                   	push   %ebx
  800839:	56                   	push   %esi
  80083a:	e8 aa fe ff ff       	call   8006e9 <printfmt>
  80083f:	83 c4 10             	add    $0x10,%esp
			err = va_arg(ap, int);
  800842:	89 7d 14             	mov    %edi,0x14(%ebp)
  800845:	e9 35 02 00 00       	jmp    800a7f <vprintfmt+0x375>
				printfmt(putch, putdat, "error %d", err);
  80084a:	50                   	push   %eax
  80084b:	68 67 2d 80 00       	push   $0x802d67
  800850:	53                   	push   %ebx
  800851:	56                   	push   %esi
  800852:	e8 92 fe ff ff       	call   8006e9 <printfmt>
  800857:	83 c4 10             	add    $0x10,%esp
			err = va_arg(ap, int);
  80085a:	89 7d 14             	mov    %edi,0x14(%ebp)
				printfmt(putch, putdat, "error %d", err);
  80085d:	e9 1d 02 00 00       	jmp    800a7f <vprintfmt+0x375>
			if ((p = va_arg(ap, char *)) == NULL)
  800862:	8b 45 14             	mov    0x14(%ebp),%eax
  800865:	83 c0 04             	add    $0x4,%eax
  800868:	89 45 c8             	mov    %eax,-0x38(%ebp)
  80086b:	8b 45 14             	mov    0x14(%ebp),%eax
  80086e:	8b 10                	mov    (%eax),%edx
				p = "(null)";
  800870:	85 d2                	test   %edx,%edx
  800872:	b8 60 2d 80 00       	mov    $0x802d60,%eax
  800877:	0f 45 c2             	cmovne %edx,%eax
  80087a:	89 45 cc             	mov    %eax,-0x34(%ebp)
			if (width > 0 && padc != '-')
  80087d:	83 7d d4 00          	cmpl   $0x0,-0x2c(%ebp)
  800881:	7e 06                	jle    800889 <vprintfmt+0x17f>
  800883:	80 7d d3 2d          	cmpb   $0x2d,-0x2d(%ebp)
  800887:	75 0d                	jne    800896 <vprintfmt+0x18c>
				for (width -= strnlen(p, precision); width > 0; width--)
  800889:	8b 45 cc             	mov    -0x34(%ebp),%eax
  80088c:	89 c7                	mov    %eax,%edi
  80088e:	03 45 d4             	add    -0x2c(%ebp),%eax
  800891:	89 45 d4             	mov    %eax,-0x2c(%ebp)
  800894:	eb 55                	jmp    8008eb <vprintfmt+0x1e1>
  800896:	83 ec 08             	sub    $0x8,%esp
  800899:	ff 75 d8             	pushl  -0x28(%ebp)
  80089c:	ff 75 cc             	pushl  -0x34(%ebp)
  80089f:	e8 15 03 00 00       	call   800bb9 <strnlen>
  8008a4:	8b 55 d4             	mov    -0x2c(%ebp),%edx
  8008a7:	29 c2                	sub    %eax,%edx
  8008a9:	89 55 c4             	mov    %edx,-0x3c(%ebp)
  8008ac:	83 c4 10             	add    $0x10,%esp
  8008af:	89 d7                	mov    %edx,%edi
					putch(padc, putdat);
  8008b1:	0f be 45 d3          	movsbl -0x2d(%ebp),%eax
  8008b5:	89 45 d4             	mov    %eax,-0x2c(%ebp)
				for (width -= strnlen(p, precision); width > 0; width--)
  8008b8:	85 ff                	test   %edi,%edi
  8008ba:	7e 11                	jle    8008cd <vprintfmt+0x1c3>
					putch(padc, putdat);
  8008bc:	83 ec 08             	sub    $0x8,%esp
  8008bf:	53                   	push   %ebx
  8008c0:	ff 75 d4             	pushl  -0x2c(%ebp)
  8008c3:	ff d6                	call   *%esi
				for (width -= strnlen(p, precision); width > 0; width--)
  8008c5:	83 ef 01             	sub    $0x1,%edi
  8008c8:	83 c4 10             	add    $0x10,%esp
  8008cb:	eb eb                	jmp    8008b8 <vprintfmt+0x1ae>
  8008cd:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  8008d0:	85 d2                	test   %edx,%edx
  8008d2:	b8 00 00 00 00       	mov    $0x0,%eax
  8008d7:	0f 49 c2             	cmovns %edx,%eax
  8008da:	29 c2                	sub    %eax,%edx
  8008dc:	89 55 d4             	mov    %edx,-0x2c(%ebp)
  8008df:	eb a8                	jmp    800889 <vprintfmt+0x17f>
					putch(ch, putdat);
  8008e1:	83 ec 08             	sub    $0x8,%esp
  8008e4:	53                   	push   %ebx
  8008e5:	52                   	push   %edx
  8008e6:	ff d6                	call   *%esi
  8008e8:	83 c4 10             	add    $0x10,%esp
  8008eb:	8b 4d d4             	mov    -0x2c(%ebp),%ecx
  8008ee:	29 f9                	sub    %edi,%ecx
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8008f0:	83 c7 01             	add    $0x1,%edi
  8008f3:	0f b6 47 ff          	movzbl -0x1(%edi),%eax
  8008f7:	0f be d0             	movsbl %al,%edx
  8008fa:	85 d2                	test   %edx,%edx
  8008fc:	74 4b                	je     800949 <vprintfmt+0x23f>
  8008fe:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  800902:	78 06                	js     80090a <vprintfmt+0x200>
  800904:	83 6d d8 01          	subl   $0x1,-0x28(%ebp)
  800908:	78 1e                	js     800928 <vprintfmt+0x21e>
				if (altflag && (ch < ' ' || ch > '~'))
  80090a:	83 7d e0 00          	cmpl   $0x0,-0x20(%ebp)
  80090e:	74 d1                	je     8008e1 <vprintfmt+0x1d7>
  800910:	0f be c0             	movsbl %al,%eax
  800913:	83 e8 20             	sub    $0x20,%eax
  800916:	83 f8 5e             	cmp    $0x5e,%eax
  800919:	76 c6                	jbe    8008e1 <vprintfmt+0x1d7>
					putch('?', putdat);
  80091b:	83 ec 08             	sub    $0x8,%esp
  80091e:	53                   	push   %ebx
  80091f:	6a 3f                	push   $0x3f
  800921:	ff d6                	call   *%esi
  800923:	83 c4 10             	add    $0x10,%esp
  800926:	eb c3                	jmp    8008eb <vprintfmt+0x1e1>
  800928:	89 cf                	mov    %ecx,%edi
  80092a:	eb 0e                	jmp    80093a <vprintfmt+0x230>
				putch(' ', putdat);
  80092c:	83 ec 08             	sub    $0x8,%esp
  80092f:	53                   	push   %ebx
  800930:	6a 20                	push   $0x20
  800932:	ff d6                	call   *%esi
			for (; width > 0; width--)
  800934:	83 ef 01             	sub    $0x1,%edi
  800937:	83 c4 10             	add    $0x10,%esp
  80093a:	85 ff                	test   %edi,%edi
  80093c:	7f ee                	jg     80092c <vprintfmt+0x222>
			if ((p = va_arg(ap, char *)) == NULL)
  80093e:	8b 45 c8             	mov    -0x38(%ebp),%eax
  800941:	89 45 14             	mov    %eax,0x14(%ebp)
  800944:	e9 36 01 00 00       	jmp    800a7f <vprintfmt+0x375>
  800949:	89 cf                	mov    %ecx,%edi
  80094b:	eb ed                	jmp    80093a <vprintfmt+0x230>
	if (lflag >= 2)
  80094d:	83 f9 01             	cmp    $0x1,%ecx
  800950:	7f 1f                	jg     800971 <vprintfmt+0x267>
	else if (lflag)
  800952:	85 c9                	test   %ecx,%ecx
  800954:	74 67                	je     8009bd <vprintfmt+0x2b3>
		return va_arg(*ap, long);
  800956:	8b 45 14             	mov    0x14(%ebp),%eax
  800959:	8b 00                	mov    (%eax),%eax
  80095b:	89 45 d8             	mov    %eax,-0x28(%ebp)
  80095e:	89 c1                	mov    %eax,%ecx
  800960:	c1 f9 1f             	sar    $0x1f,%ecx
  800963:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800966:	8b 45 14             	mov    0x14(%ebp),%eax
  800969:	8d 40 04             	lea    0x4(%eax),%eax
  80096c:	89 45 14             	mov    %eax,0x14(%ebp)
  80096f:	eb 17                	jmp    800988 <vprintfmt+0x27e>
		return va_arg(*ap, long long);
  800971:	8b 45 14             	mov    0x14(%ebp),%eax
  800974:	8b 50 04             	mov    0x4(%eax),%edx
  800977:	8b 00                	mov    (%eax),%eax
  800979:	89 45 d8             	mov    %eax,-0x28(%ebp)
  80097c:	89 55 dc             	mov    %edx,-0x24(%ebp)
  80097f:	8b 45 14             	mov    0x14(%ebp),%eax
  800982:	8d 40 08             	lea    0x8(%eax),%eax
  800985:	89 45 14             	mov    %eax,0x14(%ebp)
			if ((long long) num < 0) {
  800988:	8b 55 d8             	mov    -0x28(%ebp),%edx
  80098b:	8b 4d dc             	mov    -0x24(%ebp),%ecx
			base = 10;
  80098e:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  800993:	85 c9                	test   %ecx,%ecx
  800995:	0f 89 ca 00 00 00    	jns    800a65 <vprintfmt+0x35b>
				putch('-', putdat);
  80099b:	83 ec 08             	sub    $0x8,%esp
  80099e:	53                   	push   %ebx
  80099f:	6a 2d                	push   $0x2d
  8009a1:	ff d6                	call   *%esi
				num = -(long long) num;
  8009a3:	8b 55 d8             	mov    -0x28(%ebp),%edx
  8009a6:	8b 4d dc             	mov    -0x24(%ebp),%ecx
  8009a9:	f7 da                	neg    %edx
  8009ab:	83 d1 00             	adc    $0x0,%ecx
  8009ae:	f7 d9                	neg    %ecx
  8009b0:	83 c4 10             	add    $0x10,%esp
			base = 10;
  8009b3:	b8 0a 00 00 00       	mov    $0xa,%eax
  8009b8:	e9 a8 00 00 00       	jmp    800a65 <vprintfmt+0x35b>
		return va_arg(*ap, int);
  8009bd:	8b 45 14             	mov    0x14(%ebp),%eax
  8009c0:	8b 00                	mov    (%eax),%eax
  8009c2:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8009c5:	99                   	cltd   
  8009c6:	89 55 dc             	mov    %edx,-0x24(%ebp)
  8009c9:	8b 45 14             	mov    0x14(%ebp),%eax
  8009cc:	8d 40 04             	lea    0x4(%eax),%eax
  8009cf:	89 45 14             	mov    %eax,0x14(%ebp)
  8009d2:	eb b4                	jmp    800988 <vprintfmt+0x27e>
	if (lflag >= 2)
  8009d4:	83 f9 01             	cmp    $0x1,%ecx
  8009d7:	7f 1b                	jg     8009f4 <vprintfmt+0x2ea>
	else if (lflag)
  8009d9:	85 c9                	test   %ecx,%ecx
  8009db:	74 2c                	je     800a09 <vprintfmt+0x2ff>
		return va_arg(*ap, unsigned long);
  8009dd:	8b 45 14             	mov    0x14(%ebp),%eax
  8009e0:	8b 10                	mov    (%eax),%edx
  8009e2:	b9 00 00 00 00       	mov    $0x0,%ecx
  8009e7:	8d 40 04             	lea    0x4(%eax),%eax
  8009ea:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 10;
  8009ed:	b8 0a 00 00 00       	mov    $0xa,%eax
		return va_arg(*ap, unsigned long);
  8009f2:	eb 71                	jmp    800a65 <vprintfmt+0x35b>
		return va_arg(*ap, unsigned long long);
  8009f4:	8b 45 14             	mov    0x14(%ebp),%eax
  8009f7:	8b 10                	mov    (%eax),%edx
  8009f9:	8b 48 04             	mov    0x4(%eax),%ecx
  8009fc:	8d 40 08             	lea    0x8(%eax),%eax
  8009ff:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 10;
  800a02:	b8 0a 00 00 00       	mov    $0xa,%eax
		return va_arg(*ap, unsigned long long);
  800a07:	eb 5c                	jmp    800a65 <vprintfmt+0x35b>
		return va_arg(*ap, unsigned int);
  800a09:	8b 45 14             	mov    0x14(%ebp),%eax
  800a0c:	8b 10                	mov    (%eax),%edx
  800a0e:	b9 00 00 00 00       	mov    $0x0,%ecx
  800a13:	8d 40 04             	lea    0x4(%eax),%eax
  800a16:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 10;
  800a19:	b8 0a 00 00 00       	mov    $0xa,%eax
		return va_arg(*ap, unsigned int);
  800a1e:	eb 45                	jmp    800a65 <vprintfmt+0x35b>
			putch('X', putdat);
  800a20:	83 ec 08             	sub    $0x8,%esp
  800a23:	53                   	push   %ebx
  800a24:	6a 58                	push   $0x58
  800a26:	ff d6                	call   *%esi
			putch('X', putdat);
  800a28:	83 c4 08             	add    $0x8,%esp
  800a2b:	53                   	push   %ebx
  800a2c:	6a 58                	push   $0x58
  800a2e:	ff d6                	call   *%esi
			putch('X', putdat);
  800a30:	83 c4 08             	add    $0x8,%esp
  800a33:	53                   	push   %ebx
  800a34:	6a 58                	push   $0x58
  800a36:	ff d6                	call   *%esi
			break;
  800a38:	83 c4 10             	add    $0x10,%esp
  800a3b:	eb 42                	jmp    800a7f <vprintfmt+0x375>
			putch('0', putdat);
  800a3d:	83 ec 08             	sub    $0x8,%esp
  800a40:	53                   	push   %ebx
  800a41:	6a 30                	push   $0x30
  800a43:	ff d6                	call   *%esi
			putch('x', putdat);
  800a45:	83 c4 08             	add    $0x8,%esp
  800a48:	53                   	push   %ebx
  800a49:	6a 78                	push   $0x78
  800a4b:	ff d6                	call   *%esi
			num = (unsigned long long)
  800a4d:	8b 45 14             	mov    0x14(%ebp),%eax
  800a50:	8b 10                	mov    (%eax),%edx
  800a52:	b9 00 00 00 00       	mov    $0x0,%ecx
			goto number;
  800a57:	83 c4 10             	add    $0x10,%esp
				(uintptr_t) va_arg(ap, void *);
  800a5a:	8d 40 04             	lea    0x4(%eax),%eax
  800a5d:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 16;
  800a60:	b8 10 00 00 00       	mov    $0x10,%eax
			printnum(putch, putdat, num, base, width, padc);
  800a65:	83 ec 0c             	sub    $0xc,%esp
  800a68:	0f be 7d d3          	movsbl -0x2d(%ebp),%edi
  800a6c:	57                   	push   %edi
  800a6d:	ff 75 d4             	pushl  -0x2c(%ebp)
  800a70:	50                   	push   %eax
  800a71:	51                   	push   %ecx
  800a72:	52                   	push   %edx
  800a73:	89 da                	mov    %ebx,%edx
  800a75:	89 f0                	mov    %esi,%eax
  800a77:	e8 a3 fb ff ff       	call   80061f <printnum>
			break;
  800a7c:	83 c4 20             	add    $0x20,%esp
			if ((p = va_arg(ap, char *)) == NULL)
  800a7f:	8b 7d e4             	mov    -0x1c(%ebp),%edi
		while ((ch = *(unsigned char *) fmt++) != '%') {
  800a82:	83 c7 01             	add    $0x1,%edi
  800a85:	0f b6 47 ff          	movzbl -0x1(%edi),%eax
  800a89:	83 f8 25             	cmp    $0x25,%eax
  800a8c:	0f 84 93 fc ff ff    	je     800725 <vprintfmt+0x1b>
			if (ch == '\0')
  800a92:	85 c0                	test   %eax,%eax
  800a94:	0f 84 8b 00 00 00    	je     800b25 <vprintfmt+0x41b>
			putch(ch, putdat);
  800a9a:	83 ec 08             	sub    $0x8,%esp
  800a9d:	53                   	push   %ebx
  800a9e:	50                   	push   %eax
  800a9f:	ff d6                	call   *%esi
  800aa1:	83 c4 10             	add    $0x10,%esp
  800aa4:	eb dc                	jmp    800a82 <vprintfmt+0x378>
	if (lflag >= 2)
  800aa6:	83 f9 01             	cmp    $0x1,%ecx
  800aa9:	7f 1b                	jg     800ac6 <vprintfmt+0x3bc>
	else if (lflag)
  800aab:	85 c9                	test   %ecx,%ecx
  800aad:	74 2c                	je     800adb <vprintfmt+0x3d1>
		return va_arg(*ap, unsigned long);
  800aaf:	8b 45 14             	mov    0x14(%ebp),%eax
  800ab2:	8b 10                	mov    (%eax),%edx
  800ab4:	b9 00 00 00 00       	mov    $0x0,%ecx
  800ab9:	8d 40 04             	lea    0x4(%eax),%eax
  800abc:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 16;
  800abf:	b8 10 00 00 00       	mov    $0x10,%eax
		return va_arg(*ap, unsigned long);
  800ac4:	eb 9f                	jmp    800a65 <vprintfmt+0x35b>
		return va_arg(*ap, unsigned long long);
  800ac6:	8b 45 14             	mov    0x14(%ebp),%eax
  800ac9:	8b 10                	mov    (%eax),%edx
  800acb:	8b 48 04             	mov    0x4(%eax),%ecx
  800ace:	8d 40 08             	lea    0x8(%eax),%eax
  800ad1:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 16;
  800ad4:	b8 10 00 00 00       	mov    $0x10,%eax
		return va_arg(*ap, unsigned long long);
  800ad9:	eb 8a                	jmp    800a65 <vprintfmt+0x35b>
		return va_arg(*ap, unsigned int);
  800adb:	8b 45 14             	mov    0x14(%ebp),%eax
  800ade:	8b 10                	mov    (%eax),%edx
  800ae0:	b9 00 00 00 00       	mov    $0x0,%ecx
  800ae5:	8d 40 04             	lea    0x4(%eax),%eax
  800ae8:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 16;
  800aeb:	b8 10 00 00 00       	mov    $0x10,%eax
		return va_arg(*ap, unsigned int);
  800af0:	e9 70 ff ff ff       	jmp    800a65 <vprintfmt+0x35b>
			putch(ch, putdat);
  800af5:	83 ec 08             	sub    $0x8,%esp
  800af8:	53                   	push   %ebx
  800af9:	6a 25                	push   $0x25
  800afb:	ff d6                	call   *%esi
			break;
  800afd:	83 c4 10             	add    $0x10,%esp
  800b00:	e9 7a ff ff ff       	jmp    800a7f <vprintfmt+0x375>
			putch('%', putdat);
  800b05:	83 ec 08             	sub    $0x8,%esp
  800b08:	53                   	push   %ebx
  800b09:	6a 25                	push   $0x25
  800b0b:	ff d6                	call   *%esi
			for (fmt--; fmt[-1] != '%'; fmt--)
  800b0d:	83 c4 10             	add    $0x10,%esp
  800b10:	89 f8                	mov    %edi,%eax
  800b12:	80 78 ff 25          	cmpb   $0x25,-0x1(%eax)
  800b16:	74 05                	je     800b1d <vprintfmt+0x413>
  800b18:	83 e8 01             	sub    $0x1,%eax
  800b1b:	eb f5                	jmp    800b12 <vprintfmt+0x408>
  800b1d:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  800b20:	e9 5a ff ff ff       	jmp    800a7f <vprintfmt+0x375>
}
  800b25:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800b28:	5b                   	pop    %ebx
  800b29:	5e                   	pop    %esi
  800b2a:	5f                   	pop    %edi
  800b2b:	5d                   	pop    %ebp
  800b2c:	c3                   	ret    

00800b2d <vsnprintf>:

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  800b2d:	f3 0f 1e fb          	endbr32 
  800b31:	55                   	push   %ebp
  800b32:	89 e5                	mov    %esp,%ebp
  800b34:	83 ec 18             	sub    $0x18,%esp
  800b37:	8b 45 08             	mov    0x8(%ebp),%eax
  800b3a:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};
  800b3d:	89 45 ec             	mov    %eax,-0x14(%ebp)
  800b40:	8d 4c 10 ff          	lea    -0x1(%eax,%edx,1),%ecx
  800b44:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  800b47:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
  800b4e:	85 c0                	test   %eax,%eax
  800b50:	74 26                	je     800b78 <vsnprintf+0x4b>
  800b52:	85 d2                	test   %edx,%edx
  800b54:	7e 22                	jle    800b78 <vsnprintf+0x4b>
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  800b56:	ff 75 14             	pushl  0x14(%ebp)
  800b59:	ff 75 10             	pushl  0x10(%ebp)
  800b5c:	8d 45 ec             	lea    -0x14(%ebp),%eax
  800b5f:	50                   	push   %eax
  800b60:	68 c8 06 80 00       	push   $0x8006c8
  800b65:	e8 a0 fb ff ff       	call   80070a <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  800b6a:	8b 45 ec             	mov    -0x14(%ebp),%eax
  800b6d:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  800b70:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800b73:	83 c4 10             	add    $0x10,%esp
}
  800b76:	c9                   	leave  
  800b77:	c3                   	ret    
		return -E_INVAL;
  800b78:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  800b7d:	eb f7                	jmp    800b76 <vsnprintf+0x49>

00800b7f <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  800b7f:	f3 0f 1e fb          	endbr32 
  800b83:	55                   	push   %ebp
  800b84:	89 e5                	mov    %esp,%ebp
  800b86:	83 ec 08             	sub    $0x8,%esp
	va_list ap;
	int rc;

	va_start(ap, fmt);
  800b89:	8d 45 14             	lea    0x14(%ebp),%eax
	rc = vsnprintf(buf, n, fmt, ap);
  800b8c:	50                   	push   %eax
  800b8d:	ff 75 10             	pushl  0x10(%ebp)
  800b90:	ff 75 0c             	pushl  0xc(%ebp)
  800b93:	ff 75 08             	pushl  0x8(%ebp)
  800b96:	e8 92 ff ff ff       	call   800b2d <vsnprintf>
	va_end(ap);

	return rc;
}
  800b9b:	c9                   	leave  
  800b9c:	c3                   	ret    

00800b9d <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  800b9d:	f3 0f 1e fb          	endbr32 
  800ba1:	55                   	push   %ebp
  800ba2:	89 e5                	mov    %esp,%ebp
  800ba4:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  800ba7:	b8 00 00 00 00       	mov    $0x0,%eax
  800bac:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  800bb0:	74 05                	je     800bb7 <strlen+0x1a>
		n++;
  800bb2:	83 c0 01             	add    $0x1,%eax
  800bb5:	eb f5                	jmp    800bac <strlen+0xf>
	return n;
}
  800bb7:	5d                   	pop    %ebp
  800bb8:	c3                   	ret    

00800bb9 <strnlen>:

int
strnlen(const char *s, size_t size)
{
  800bb9:	f3 0f 1e fb          	endbr32 
  800bbd:	55                   	push   %ebp
  800bbe:	89 e5                	mov    %esp,%ebp
  800bc0:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800bc3:	8b 55 0c             	mov    0xc(%ebp),%edx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800bc6:	b8 00 00 00 00       	mov    $0x0,%eax
  800bcb:	39 d0                	cmp    %edx,%eax
  800bcd:	74 0d                	je     800bdc <strnlen+0x23>
  800bcf:	80 3c 01 00          	cmpb   $0x0,(%ecx,%eax,1)
  800bd3:	74 05                	je     800bda <strnlen+0x21>
		n++;
  800bd5:	83 c0 01             	add    $0x1,%eax
  800bd8:	eb f1                	jmp    800bcb <strnlen+0x12>
  800bda:	89 c2                	mov    %eax,%edx
	return n;
}
  800bdc:	89 d0                	mov    %edx,%eax
  800bde:	5d                   	pop    %ebp
  800bdf:	c3                   	ret    

00800be0 <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  800be0:	f3 0f 1e fb          	endbr32 
  800be4:	55                   	push   %ebp
  800be5:	89 e5                	mov    %esp,%ebp
  800be7:	53                   	push   %ebx
  800be8:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800beb:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  800bee:	b8 00 00 00 00       	mov    $0x0,%eax
  800bf3:	0f b6 14 03          	movzbl (%ebx,%eax,1),%edx
  800bf7:	88 14 01             	mov    %dl,(%ecx,%eax,1)
  800bfa:	83 c0 01             	add    $0x1,%eax
  800bfd:	84 d2                	test   %dl,%dl
  800bff:	75 f2                	jne    800bf3 <strcpy+0x13>
		/* do nothing */;
	return ret;
}
  800c01:	89 c8                	mov    %ecx,%eax
  800c03:	5b                   	pop    %ebx
  800c04:	5d                   	pop    %ebp
  800c05:	c3                   	ret    

00800c06 <strcat>:

char *
strcat(char *dst, const char *src)
{
  800c06:	f3 0f 1e fb          	endbr32 
  800c0a:	55                   	push   %ebp
  800c0b:	89 e5                	mov    %esp,%ebp
  800c0d:	53                   	push   %ebx
  800c0e:	83 ec 10             	sub    $0x10,%esp
  800c11:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int len = strlen(dst);
  800c14:	53                   	push   %ebx
  800c15:	e8 83 ff ff ff       	call   800b9d <strlen>
  800c1a:	83 c4 08             	add    $0x8,%esp
	strcpy(dst + len, src);
  800c1d:	ff 75 0c             	pushl  0xc(%ebp)
  800c20:	01 d8                	add    %ebx,%eax
  800c22:	50                   	push   %eax
  800c23:	e8 b8 ff ff ff       	call   800be0 <strcpy>
	return dst;
}
  800c28:	89 d8                	mov    %ebx,%eax
  800c2a:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  800c2d:	c9                   	leave  
  800c2e:	c3                   	ret    

00800c2f <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  800c2f:	f3 0f 1e fb          	endbr32 
  800c33:	55                   	push   %ebp
  800c34:	89 e5                	mov    %esp,%ebp
  800c36:	56                   	push   %esi
  800c37:	53                   	push   %ebx
  800c38:	8b 75 08             	mov    0x8(%ebp),%esi
  800c3b:	8b 55 0c             	mov    0xc(%ebp),%edx
  800c3e:	89 f3                	mov    %esi,%ebx
  800c40:	03 5d 10             	add    0x10(%ebp),%ebx
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800c43:	89 f0                	mov    %esi,%eax
  800c45:	39 d8                	cmp    %ebx,%eax
  800c47:	74 11                	je     800c5a <strncpy+0x2b>
		*dst++ = *src;
  800c49:	83 c0 01             	add    $0x1,%eax
  800c4c:	0f b6 0a             	movzbl (%edx),%ecx
  800c4f:	88 48 ff             	mov    %cl,-0x1(%eax)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  800c52:	80 f9 01             	cmp    $0x1,%cl
  800c55:	83 da ff             	sbb    $0xffffffff,%edx
  800c58:	eb eb                	jmp    800c45 <strncpy+0x16>
	}
	return ret;
}
  800c5a:	89 f0                	mov    %esi,%eax
  800c5c:	5b                   	pop    %ebx
  800c5d:	5e                   	pop    %esi
  800c5e:	5d                   	pop    %ebp
  800c5f:	c3                   	ret    

00800c60 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  800c60:	f3 0f 1e fb          	endbr32 
  800c64:	55                   	push   %ebp
  800c65:	89 e5                	mov    %esp,%ebp
  800c67:	56                   	push   %esi
  800c68:	53                   	push   %ebx
  800c69:	8b 75 08             	mov    0x8(%ebp),%esi
  800c6c:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800c6f:	8b 55 10             	mov    0x10(%ebp),%edx
  800c72:	89 f0                	mov    %esi,%eax
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  800c74:	85 d2                	test   %edx,%edx
  800c76:	74 21                	je     800c99 <strlcpy+0x39>
  800c78:	8d 44 16 ff          	lea    -0x1(%esi,%edx,1),%eax
  800c7c:	89 f2                	mov    %esi,%edx
		while (--size > 0 && *src != '\0')
  800c7e:	39 c2                	cmp    %eax,%edx
  800c80:	74 14                	je     800c96 <strlcpy+0x36>
  800c82:	0f b6 19             	movzbl (%ecx),%ebx
  800c85:	84 db                	test   %bl,%bl
  800c87:	74 0b                	je     800c94 <strlcpy+0x34>
			*dst++ = *src++;
  800c89:	83 c1 01             	add    $0x1,%ecx
  800c8c:	83 c2 01             	add    $0x1,%edx
  800c8f:	88 5a ff             	mov    %bl,-0x1(%edx)
  800c92:	eb ea                	jmp    800c7e <strlcpy+0x1e>
  800c94:	89 d0                	mov    %edx,%eax
		*dst = '\0';
  800c96:	c6 00 00             	movb   $0x0,(%eax)
	}
	return dst - dst_in;
  800c99:	29 f0                	sub    %esi,%eax
}
  800c9b:	5b                   	pop    %ebx
  800c9c:	5e                   	pop    %esi
  800c9d:	5d                   	pop    %ebp
  800c9e:	c3                   	ret    

00800c9f <strcmp>:

int
strcmp(const char *p, const char *q)
{
  800c9f:	f3 0f 1e fb          	endbr32 
  800ca3:	55                   	push   %ebp
  800ca4:	89 e5                	mov    %esp,%ebp
  800ca6:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800ca9:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  800cac:	0f b6 01             	movzbl (%ecx),%eax
  800caf:	84 c0                	test   %al,%al
  800cb1:	74 0c                	je     800cbf <strcmp+0x20>
  800cb3:	3a 02                	cmp    (%edx),%al
  800cb5:	75 08                	jne    800cbf <strcmp+0x20>
		p++, q++;
  800cb7:	83 c1 01             	add    $0x1,%ecx
  800cba:	83 c2 01             	add    $0x1,%edx
  800cbd:	eb ed                	jmp    800cac <strcmp+0xd>
	return (int) ((unsigned char) *p - (unsigned char) *q);
  800cbf:	0f b6 c0             	movzbl %al,%eax
  800cc2:	0f b6 12             	movzbl (%edx),%edx
  800cc5:	29 d0                	sub    %edx,%eax
}
  800cc7:	5d                   	pop    %ebp
  800cc8:	c3                   	ret    

00800cc9 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  800cc9:	f3 0f 1e fb          	endbr32 
  800ccd:	55                   	push   %ebp
  800cce:	89 e5                	mov    %esp,%ebp
  800cd0:	53                   	push   %ebx
  800cd1:	8b 45 08             	mov    0x8(%ebp),%eax
  800cd4:	8b 55 0c             	mov    0xc(%ebp),%edx
  800cd7:	89 c3                	mov    %eax,%ebx
  800cd9:	03 5d 10             	add    0x10(%ebp),%ebx
	while (n > 0 && *p && *p == *q)
  800cdc:	eb 06                	jmp    800ce4 <strncmp+0x1b>
		n--, p++, q++;
  800cde:	83 c0 01             	add    $0x1,%eax
  800ce1:	83 c2 01             	add    $0x1,%edx
	while (n > 0 && *p && *p == *q)
  800ce4:	39 d8                	cmp    %ebx,%eax
  800ce6:	74 16                	je     800cfe <strncmp+0x35>
  800ce8:	0f b6 08             	movzbl (%eax),%ecx
  800ceb:	84 c9                	test   %cl,%cl
  800ced:	74 04                	je     800cf3 <strncmp+0x2a>
  800cef:	3a 0a                	cmp    (%edx),%cl
  800cf1:	74 eb                	je     800cde <strncmp+0x15>
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  800cf3:	0f b6 00             	movzbl (%eax),%eax
  800cf6:	0f b6 12             	movzbl (%edx),%edx
  800cf9:	29 d0                	sub    %edx,%eax
}
  800cfb:	5b                   	pop    %ebx
  800cfc:	5d                   	pop    %ebp
  800cfd:	c3                   	ret    
		return 0;
  800cfe:	b8 00 00 00 00       	mov    $0x0,%eax
  800d03:	eb f6                	jmp    800cfb <strncmp+0x32>

00800d05 <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  800d05:	f3 0f 1e fb          	endbr32 
  800d09:	55                   	push   %ebp
  800d0a:	89 e5                	mov    %esp,%ebp
  800d0c:	8b 45 08             	mov    0x8(%ebp),%eax
  800d0f:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800d13:	0f b6 10             	movzbl (%eax),%edx
  800d16:	84 d2                	test   %dl,%dl
  800d18:	74 09                	je     800d23 <strchr+0x1e>
		if (*s == c)
  800d1a:	38 ca                	cmp    %cl,%dl
  800d1c:	74 0a                	je     800d28 <strchr+0x23>
	for (; *s; s++)
  800d1e:	83 c0 01             	add    $0x1,%eax
  800d21:	eb f0                	jmp    800d13 <strchr+0xe>
			return (char *) s;
	return 0;
  800d23:	b8 00 00 00 00       	mov    $0x0,%eax
}
  800d28:	5d                   	pop    %ebp
  800d29:	c3                   	ret    

00800d2a <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  800d2a:	f3 0f 1e fb          	endbr32 
  800d2e:	55                   	push   %ebp
  800d2f:	89 e5                	mov    %esp,%ebp
  800d31:	8b 45 08             	mov    0x8(%ebp),%eax
  800d34:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800d38:	0f b6 10             	movzbl (%eax),%edx
		if (*s == c)
  800d3b:	38 ca                	cmp    %cl,%dl
  800d3d:	74 09                	je     800d48 <strfind+0x1e>
  800d3f:	84 d2                	test   %dl,%dl
  800d41:	74 05                	je     800d48 <strfind+0x1e>
	for (; *s; s++)
  800d43:	83 c0 01             	add    $0x1,%eax
  800d46:	eb f0                	jmp    800d38 <strfind+0xe>
			break;
	return (char *) s;
}
  800d48:	5d                   	pop    %ebp
  800d49:	c3                   	ret    

00800d4a <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  800d4a:	f3 0f 1e fb          	endbr32 
  800d4e:	55                   	push   %ebp
  800d4f:	89 e5                	mov    %esp,%ebp
  800d51:	57                   	push   %edi
  800d52:	56                   	push   %esi
  800d53:	53                   	push   %ebx
  800d54:	8b 7d 08             	mov    0x8(%ebp),%edi
  800d57:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  800d5a:	85 c9                	test   %ecx,%ecx
  800d5c:	74 31                	je     800d8f <memset+0x45>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800d5e:	89 f8                	mov    %edi,%eax
  800d60:	09 c8                	or     %ecx,%eax
  800d62:	a8 03                	test   $0x3,%al
  800d64:	75 23                	jne    800d89 <memset+0x3f>
		c &= 0xFF;
  800d66:	0f b6 55 0c          	movzbl 0xc(%ebp),%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  800d6a:	89 d3                	mov    %edx,%ebx
  800d6c:	c1 e3 08             	shl    $0x8,%ebx
  800d6f:	89 d0                	mov    %edx,%eax
  800d71:	c1 e0 18             	shl    $0x18,%eax
  800d74:	89 d6                	mov    %edx,%esi
  800d76:	c1 e6 10             	shl    $0x10,%esi
  800d79:	09 f0                	or     %esi,%eax
  800d7b:	09 c2                	or     %eax,%edx
  800d7d:	09 da                	or     %ebx,%edx
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
  800d7f:	c1 e9 02             	shr    $0x2,%ecx
		asm volatile("cld; rep stosl\n"
  800d82:	89 d0                	mov    %edx,%eax
  800d84:	fc                   	cld    
  800d85:	f3 ab                	rep stos %eax,%es:(%edi)
  800d87:	eb 06                	jmp    800d8f <memset+0x45>
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  800d89:	8b 45 0c             	mov    0xc(%ebp),%eax
  800d8c:	fc                   	cld    
  800d8d:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  800d8f:	89 f8                	mov    %edi,%eax
  800d91:	5b                   	pop    %ebx
  800d92:	5e                   	pop    %esi
  800d93:	5f                   	pop    %edi
  800d94:	5d                   	pop    %ebp
  800d95:	c3                   	ret    

00800d96 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  800d96:	f3 0f 1e fb          	endbr32 
  800d9a:	55                   	push   %ebp
  800d9b:	89 e5                	mov    %esp,%ebp
  800d9d:	57                   	push   %edi
  800d9e:	56                   	push   %esi
  800d9f:	8b 45 08             	mov    0x8(%ebp),%eax
  800da2:	8b 75 0c             	mov    0xc(%ebp),%esi
  800da5:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;

	s = src;
	d = dst;
	if (s < d && s + n > d) {
  800da8:	39 c6                	cmp    %eax,%esi
  800daa:	73 32                	jae    800dde <memmove+0x48>
  800dac:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  800daf:	39 c2                	cmp    %eax,%edx
  800db1:	76 2b                	jbe    800dde <memmove+0x48>
		s += n;
		d += n;
  800db3:	8d 3c 08             	lea    (%eax,%ecx,1),%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800db6:	89 fe                	mov    %edi,%esi
  800db8:	09 ce                	or     %ecx,%esi
  800dba:	09 d6                	or     %edx,%esi
  800dbc:	f7 c6 03 00 00 00    	test   $0x3,%esi
  800dc2:	75 0e                	jne    800dd2 <memmove+0x3c>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
  800dc4:	83 ef 04             	sub    $0x4,%edi
  800dc7:	8d 72 fc             	lea    -0x4(%edx),%esi
  800dca:	c1 e9 02             	shr    $0x2,%ecx
			asm volatile("std; rep movsl\n"
  800dcd:	fd                   	std    
  800dce:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
  800dd0:	eb 09                	jmp    800ddb <memmove+0x45>
		else
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
  800dd2:	83 ef 01             	sub    $0x1,%edi
  800dd5:	8d 72 ff             	lea    -0x1(%edx),%esi
			asm volatile("std; rep movsb\n"
  800dd8:	fd                   	std    
  800dd9:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  800ddb:	fc                   	cld    
  800ddc:	eb 1a                	jmp    800df8 <memmove+0x62>
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800dde:	89 c2                	mov    %eax,%edx
  800de0:	09 ca                	or     %ecx,%edx
  800de2:	09 f2                	or     %esi,%edx
  800de4:	f6 c2 03             	test   $0x3,%dl
  800de7:	75 0a                	jne    800df3 <memmove+0x5d>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
  800de9:	c1 e9 02             	shr    $0x2,%ecx
			asm volatile("cld; rep movsl\n"
  800dec:	89 c7                	mov    %eax,%edi
  800dee:	fc                   	cld    
  800def:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
  800df1:	eb 05                	jmp    800df8 <memmove+0x62>
		else
			asm volatile("cld; rep movsb\n"
  800df3:	89 c7                	mov    %eax,%edi
  800df5:	fc                   	cld    
  800df6:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  800df8:	5e                   	pop    %esi
  800df9:	5f                   	pop    %edi
  800dfa:	5d                   	pop    %ebp
  800dfb:	c3                   	ret    

00800dfc <memcpy>:
}
#endif

void *
memcpy(void *dst, const void *src, size_t n)
{
  800dfc:	f3 0f 1e fb          	endbr32 
  800e00:	55                   	push   %ebp
  800e01:	89 e5                	mov    %esp,%ebp
  800e03:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  800e06:	ff 75 10             	pushl  0x10(%ebp)
  800e09:	ff 75 0c             	pushl  0xc(%ebp)
  800e0c:	ff 75 08             	pushl  0x8(%ebp)
  800e0f:	e8 82 ff ff ff       	call   800d96 <memmove>
}
  800e14:	c9                   	leave  
  800e15:	c3                   	ret    

00800e16 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  800e16:	f3 0f 1e fb          	endbr32 
  800e1a:	55                   	push   %ebp
  800e1b:	89 e5                	mov    %esp,%ebp
  800e1d:	56                   	push   %esi
  800e1e:	53                   	push   %ebx
  800e1f:	8b 45 08             	mov    0x8(%ebp),%eax
  800e22:	8b 55 0c             	mov    0xc(%ebp),%edx
  800e25:	89 c6                	mov    %eax,%esi
  800e27:	03 75 10             	add    0x10(%ebp),%esi
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800e2a:	39 f0                	cmp    %esi,%eax
  800e2c:	74 1c                	je     800e4a <memcmp+0x34>
		if (*s1 != *s2)
  800e2e:	0f b6 08             	movzbl (%eax),%ecx
  800e31:	0f b6 1a             	movzbl (%edx),%ebx
  800e34:	38 d9                	cmp    %bl,%cl
  800e36:	75 08                	jne    800e40 <memcmp+0x2a>
			return (int) *s1 - (int) *s2;
		s1++, s2++;
  800e38:	83 c0 01             	add    $0x1,%eax
  800e3b:	83 c2 01             	add    $0x1,%edx
  800e3e:	eb ea                	jmp    800e2a <memcmp+0x14>
			return (int) *s1 - (int) *s2;
  800e40:	0f b6 c1             	movzbl %cl,%eax
  800e43:	0f b6 db             	movzbl %bl,%ebx
  800e46:	29 d8                	sub    %ebx,%eax
  800e48:	eb 05                	jmp    800e4f <memcmp+0x39>
	}

	return 0;
  800e4a:	b8 00 00 00 00       	mov    $0x0,%eax
}
  800e4f:	5b                   	pop    %ebx
  800e50:	5e                   	pop    %esi
  800e51:	5d                   	pop    %ebp
  800e52:	c3                   	ret    

00800e53 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  800e53:	f3 0f 1e fb          	endbr32 
  800e57:	55                   	push   %ebp
  800e58:	89 e5                	mov    %esp,%ebp
  800e5a:	8b 45 08             	mov    0x8(%ebp),%eax
  800e5d:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	const void *ends = (const char *) s + n;
  800e60:	89 c2                	mov    %eax,%edx
  800e62:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  800e65:	39 d0                	cmp    %edx,%eax
  800e67:	73 09                	jae    800e72 <memfind+0x1f>
		if (*(const unsigned char *) s == (unsigned char) c)
  800e69:	38 08                	cmp    %cl,(%eax)
  800e6b:	74 05                	je     800e72 <memfind+0x1f>
	for (; s < ends; s++)
  800e6d:	83 c0 01             	add    $0x1,%eax
  800e70:	eb f3                	jmp    800e65 <memfind+0x12>
			break;
	return (void *) s;
}
  800e72:	5d                   	pop    %ebp
  800e73:	c3                   	ret    

00800e74 <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  800e74:	f3 0f 1e fb          	endbr32 
  800e78:	55                   	push   %ebp
  800e79:	89 e5                	mov    %esp,%ebp
  800e7b:	57                   	push   %edi
  800e7c:	56                   	push   %esi
  800e7d:	53                   	push   %ebx
  800e7e:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800e81:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800e84:	eb 03                	jmp    800e89 <strtol+0x15>
		s++;
  800e86:	83 c1 01             	add    $0x1,%ecx
	while (*s == ' ' || *s == '\t')
  800e89:	0f b6 01             	movzbl (%ecx),%eax
  800e8c:	3c 20                	cmp    $0x20,%al
  800e8e:	74 f6                	je     800e86 <strtol+0x12>
  800e90:	3c 09                	cmp    $0x9,%al
  800e92:	74 f2                	je     800e86 <strtol+0x12>

	// plus/minus sign
	if (*s == '+')
  800e94:	3c 2b                	cmp    $0x2b,%al
  800e96:	74 2a                	je     800ec2 <strtol+0x4e>
	int neg = 0;
  800e98:	bf 00 00 00 00       	mov    $0x0,%edi
		s++;
	else if (*s == '-')
  800e9d:	3c 2d                	cmp    $0x2d,%al
  800e9f:	74 2b                	je     800ecc <strtol+0x58>
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800ea1:	f7 c3 ef ff ff ff    	test   $0xffffffef,%ebx
  800ea7:	75 0f                	jne    800eb8 <strtol+0x44>
  800ea9:	80 39 30             	cmpb   $0x30,(%ecx)
  800eac:	74 28                	je     800ed6 <strtol+0x62>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
		s++, base = 8;
	else if (base == 0)
		base = 10;
  800eae:	85 db                	test   %ebx,%ebx
  800eb0:	b8 0a 00 00 00       	mov    $0xa,%eax
  800eb5:	0f 44 d8             	cmove  %eax,%ebx
  800eb8:	b8 00 00 00 00       	mov    $0x0,%eax
  800ebd:	89 5d 10             	mov    %ebx,0x10(%ebp)
  800ec0:	eb 46                	jmp    800f08 <strtol+0x94>
		s++;
  800ec2:	83 c1 01             	add    $0x1,%ecx
	int neg = 0;
  800ec5:	bf 00 00 00 00       	mov    $0x0,%edi
  800eca:	eb d5                	jmp    800ea1 <strtol+0x2d>
		s++, neg = 1;
  800ecc:	83 c1 01             	add    $0x1,%ecx
  800ecf:	bf 01 00 00 00       	mov    $0x1,%edi
  800ed4:	eb cb                	jmp    800ea1 <strtol+0x2d>
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800ed6:	80 79 01 78          	cmpb   $0x78,0x1(%ecx)
  800eda:	74 0e                	je     800eea <strtol+0x76>
	else if (base == 0 && s[0] == '0')
  800edc:	85 db                	test   %ebx,%ebx
  800ede:	75 d8                	jne    800eb8 <strtol+0x44>
		s++, base = 8;
  800ee0:	83 c1 01             	add    $0x1,%ecx
  800ee3:	bb 08 00 00 00       	mov    $0x8,%ebx
  800ee8:	eb ce                	jmp    800eb8 <strtol+0x44>
		s += 2, base = 16;
  800eea:	83 c1 02             	add    $0x2,%ecx
  800eed:	bb 10 00 00 00       	mov    $0x10,%ebx
  800ef2:	eb c4                	jmp    800eb8 <strtol+0x44>
	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
			dig = *s - '0';
  800ef4:	0f be d2             	movsbl %dl,%edx
  800ef7:	83 ea 30             	sub    $0x30,%edx
			dig = *s - 'a' + 10;
		else if (*s >= 'A' && *s <= 'Z')
			dig = *s - 'A' + 10;
		else
			break;
		if (dig >= base)
  800efa:	3b 55 10             	cmp    0x10(%ebp),%edx
  800efd:	7d 3a                	jge    800f39 <strtol+0xc5>
			break;
		s++, val = (val * base) + dig;
  800eff:	83 c1 01             	add    $0x1,%ecx
  800f02:	0f af 45 10          	imul   0x10(%ebp),%eax
  800f06:	01 d0                	add    %edx,%eax
		if (*s >= '0' && *s <= '9')
  800f08:	0f b6 11             	movzbl (%ecx),%edx
  800f0b:	8d 72 d0             	lea    -0x30(%edx),%esi
  800f0e:	89 f3                	mov    %esi,%ebx
  800f10:	80 fb 09             	cmp    $0x9,%bl
  800f13:	76 df                	jbe    800ef4 <strtol+0x80>
		else if (*s >= 'a' && *s <= 'z')
  800f15:	8d 72 9f             	lea    -0x61(%edx),%esi
  800f18:	89 f3                	mov    %esi,%ebx
  800f1a:	80 fb 19             	cmp    $0x19,%bl
  800f1d:	77 08                	ja     800f27 <strtol+0xb3>
			dig = *s - 'a' + 10;
  800f1f:	0f be d2             	movsbl %dl,%edx
  800f22:	83 ea 57             	sub    $0x57,%edx
  800f25:	eb d3                	jmp    800efa <strtol+0x86>
		else if (*s >= 'A' && *s <= 'Z')
  800f27:	8d 72 bf             	lea    -0x41(%edx),%esi
  800f2a:	89 f3                	mov    %esi,%ebx
  800f2c:	80 fb 19             	cmp    $0x19,%bl
  800f2f:	77 08                	ja     800f39 <strtol+0xc5>
			dig = *s - 'A' + 10;
  800f31:	0f be d2             	movsbl %dl,%edx
  800f34:	83 ea 37             	sub    $0x37,%edx
  800f37:	eb c1                	jmp    800efa <strtol+0x86>
		// we don't properly detect overflow!
	}

	if (endptr)
  800f39:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  800f3d:	74 05                	je     800f44 <strtol+0xd0>
		*endptr = (char *) s;
  800f3f:	8b 75 0c             	mov    0xc(%ebp),%esi
  800f42:	89 0e                	mov    %ecx,(%esi)
	return (neg ? -val : val);
  800f44:	89 c2                	mov    %eax,%edx
  800f46:	f7 da                	neg    %edx
  800f48:	85 ff                	test   %edi,%edi
  800f4a:	0f 45 c2             	cmovne %edx,%eax
}
  800f4d:	5b                   	pop    %ebx
  800f4e:	5e                   	pop    %esi
  800f4f:	5f                   	pop    %edi
  800f50:	5d                   	pop    %ebp
  800f51:	c3                   	ret    

00800f52 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  800f52:	f3 0f 1e fb          	endbr32 
  800f56:	55                   	push   %ebp
  800f57:	89 e5                	mov    %esp,%ebp
  800f59:	57                   	push   %edi
  800f5a:	56                   	push   %esi
  800f5b:	53                   	push   %ebx
	asm volatile("int %1\n"
  800f5c:	b8 00 00 00 00       	mov    $0x0,%eax
  800f61:	8b 55 08             	mov    0x8(%ebp),%edx
  800f64:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f67:	89 c3                	mov    %eax,%ebx
  800f69:	89 c7                	mov    %eax,%edi
  800f6b:	89 c6                	mov    %eax,%esi
  800f6d:	cd 30                	int    $0x30
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  800f6f:	5b                   	pop    %ebx
  800f70:	5e                   	pop    %esi
  800f71:	5f                   	pop    %edi
  800f72:	5d                   	pop    %ebp
  800f73:	c3                   	ret    

00800f74 <sys_cgetc>:

int
sys_cgetc(void)
{
  800f74:	f3 0f 1e fb          	endbr32 
  800f78:	55                   	push   %ebp
  800f79:	89 e5                	mov    %esp,%ebp
  800f7b:	57                   	push   %edi
  800f7c:	56                   	push   %esi
  800f7d:	53                   	push   %ebx
	asm volatile("int %1\n"
  800f7e:	ba 00 00 00 00       	mov    $0x0,%edx
  800f83:	b8 01 00 00 00       	mov    $0x1,%eax
  800f88:	89 d1                	mov    %edx,%ecx
  800f8a:	89 d3                	mov    %edx,%ebx
  800f8c:	89 d7                	mov    %edx,%edi
  800f8e:	89 d6                	mov    %edx,%esi
  800f90:	cd 30                	int    $0x30
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  800f92:	5b                   	pop    %ebx
  800f93:	5e                   	pop    %esi
  800f94:	5f                   	pop    %edi
  800f95:	5d                   	pop    %ebp
  800f96:	c3                   	ret    

00800f97 <sys_env_destroy>:

int
sys_env_destroy(envid_t envid)
{
  800f97:	f3 0f 1e fb          	endbr32 
  800f9b:	55                   	push   %ebp
  800f9c:	89 e5                	mov    %esp,%ebp
  800f9e:	57                   	push   %edi
  800f9f:	56                   	push   %esi
  800fa0:	53                   	push   %ebx
  800fa1:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800fa4:	b9 00 00 00 00       	mov    $0x0,%ecx
  800fa9:	8b 55 08             	mov    0x8(%ebp),%edx
  800fac:	b8 03 00 00 00       	mov    $0x3,%eax
  800fb1:	89 cb                	mov    %ecx,%ebx
  800fb3:	89 cf                	mov    %ecx,%edi
  800fb5:	89 ce                	mov    %ecx,%esi
  800fb7:	cd 30                	int    $0x30
	if(check && ret > 0)
  800fb9:	85 c0                	test   %eax,%eax
  800fbb:	7f 08                	jg     800fc5 <sys_env_destroy+0x2e>
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  800fbd:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800fc0:	5b                   	pop    %ebx
  800fc1:	5e                   	pop    %esi
  800fc2:	5f                   	pop    %edi
  800fc3:	5d                   	pop    %ebp
  800fc4:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800fc5:	83 ec 0c             	sub    $0xc,%esp
  800fc8:	50                   	push   %eax
  800fc9:	6a 03                	push   $0x3
  800fcb:	68 5f 30 80 00       	push   $0x80305f
  800fd0:	6a 23                	push   $0x23
  800fd2:	68 7c 30 80 00       	push   $0x80307c
  800fd7:	e8 44 f5 ff ff       	call   800520 <_panic>

00800fdc <sys_getenvid>:

envid_t
sys_getenvid(void)
{
  800fdc:	f3 0f 1e fb          	endbr32 
  800fe0:	55                   	push   %ebp
  800fe1:	89 e5                	mov    %esp,%ebp
  800fe3:	57                   	push   %edi
  800fe4:	56                   	push   %esi
  800fe5:	53                   	push   %ebx
	asm volatile("int %1\n"
  800fe6:	ba 00 00 00 00       	mov    $0x0,%edx
  800feb:	b8 02 00 00 00       	mov    $0x2,%eax
  800ff0:	89 d1                	mov    %edx,%ecx
  800ff2:	89 d3                	mov    %edx,%ebx
  800ff4:	89 d7                	mov    %edx,%edi
  800ff6:	89 d6                	mov    %edx,%esi
  800ff8:	cd 30                	int    $0x30
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  800ffa:	5b                   	pop    %ebx
  800ffb:	5e                   	pop    %esi
  800ffc:	5f                   	pop    %edi
  800ffd:	5d                   	pop    %ebp
  800ffe:	c3                   	ret    

00800fff <sys_yield>:

void
sys_yield(void)
{
  800fff:	f3 0f 1e fb          	endbr32 
  801003:	55                   	push   %ebp
  801004:	89 e5                	mov    %esp,%ebp
  801006:	57                   	push   %edi
  801007:	56                   	push   %esi
  801008:	53                   	push   %ebx
	asm volatile("int %1\n"
  801009:	ba 00 00 00 00       	mov    $0x0,%edx
  80100e:	b8 0b 00 00 00       	mov    $0xb,%eax
  801013:	89 d1                	mov    %edx,%ecx
  801015:	89 d3                	mov    %edx,%ebx
  801017:	89 d7                	mov    %edx,%edi
  801019:	89 d6                	mov    %edx,%esi
  80101b:	cd 30                	int    $0x30
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  80101d:	5b                   	pop    %ebx
  80101e:	5e                   	pop    %esi
  80101f:	5f                   	pop    %edi
  801020:	5d                   	pop    %ebp
  801021:	c3                   	ret    

00801022 <sys_page_alloc>:

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  801022:	f3 0f 1e fb          	endbr32 
  801026:	55                   	push   %ebp
  801027:	89 e5                	mov    %esp,%ebp
  801029:	57                   	push   %edi
  80102a:	56                   	push   %esi
  80102b:	53                   	push   %ebx
  80102c:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  80102f:	be 00 00 00 00       	mov    $0x0,%esi
  801034:	8b 55 08             	mov    0x8(%ebp),%edx
  801037:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80103a:	b8 04 00 00 00       	mov    $0x4,%eax
  80103f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801042:	89 f7                	mov    %esi,%edi
  801044:	cd 30                	int    $0x30
	if(check && ret > 0)
  801046:	85 c0                	test   %eax,%eax
  801048:	7f 08                	jg     801052 <sys_page_alloc+0x30>
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  80104a:	8d 65 f4             	lea    -0xc(%ebp),%esp
  80104d:	5b                   	pop    %ebx
  80104e:	5e                   	pop    %esi
  80104f:	5f                   	pop    %edi
  801050:	5d                   	pop    %ebp
  801051:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  801052:	83 ec 0c             	sub    $0xc,%esp
  801055:	50                   	push   %eax
  801056:	6a 04                	push   $0x4
  801058:	68 5f 30 80 00       	push   $0x80305f
  80105d:	6a 23                	push   $0x23
  80105f:	68 7c 30 80 00       	push   $0x80307c
  801064:	e8 b7 f4 ff ff       	call   800520 <_panic>

00801069 <sys_page_map>:

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  801069:	f3 0f 1e fb          	endbr32 
  80106d:	55                   	push   %ebp
  80106e:	89 e5                	mov    %esp,%ebp
  801070:	57                   	push   %edi
  801071:	56                   	push   %esi
  801072:	53                   	push   %ebx
  801073:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  801076:	8b 55 08             	mov    0x8(%ebp),%edx
  801079:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80107c:	b8 05 00 00 00       	mov    $0x5,%eax
  801081:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801084:	8b 7d 14             	mov    0x14(%ebp),%edi
  801087:	8b 75 18             	mov    0x18(%ebp),%esi
  80108a:	cd 30                	int    $0x30
	if(check && ret > 0)
  80108c:	85 c0                	test   %eax,%eax
  80108e:	7f 08                	jg     801098 <sys_page_map+0x2f>
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  801090:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801093:	5b                   	pop    %ebx
  801094:	5e                   	pop    %esi
  801095:	5f                   	pop    %edi
  801096:	5d                   	pop    %ebp
  801097:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  801098:	83 ec 0c             	sub    $0xc,%esp
  80109b:	50                   	push   %eax
  80109c:	6a 05                	push   $0x5
  80109e:	68 5f 30 80 00       	push   $0x80305f
  8010a3:	6a 23                	push   $0x23
  8010a5:	68 7c 30 80 00       	push   $0x80307c
  8010aa:	e8 71 f4 ff ff       	call   800520 <_panic>

008010af <sys_page_unmap>:

int
sys_page_unmap(envid_t envid, void *va)
{
  8010af:	f3 0f 1e fb          	endbr32 
  8010b3:	55                   	push   %ebp
  8010b4:	89 e5                	mov    %esp,%ebp
  8010b6:	57                   	push   %edi
  8010b7:	56                   	push   %esi
  8010b8:	53                   	push   %ebx
  8010b9:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  8010bc:	bb 00 00 00 00       	mov    $0x0,%ebx
  8010c1:	8b 55 08             	mov    0x8(%ebp),%edx
  8010c4:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8010c7:	b8 06 00 00 00       	mov    $0x6,%eax
  8010cc:	89 df                	mov    %ebx,%edi
  8010ce:	89 de                	mov    %ebx,%esi
  8010d0:	cd 30                	int    $0x30
	if(check && ret > 0)
  8010d2:	85 c0                	test   %eax,%eax
  8010d4:	7f 08                	jg     8010de <sys_page_unmap+0x2f>
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  8010d6:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8010d9:	5b                   	pop    %ebx
  8010da:	5e                   	pop    %esi
  8010db:	5f                   	pop    %edi
  8010dc:	5d                   	pop    %ebp
  8010dd:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  8010de:	83 ec 0c             	sub    $0xc,%esp
  8010e1:	50                   	push   %eax
  8010e2:	6a 06                	push   $0x6
  8010e4:	68 5f 30 80 00       	push   $0x80305f
  8010e9:	6a 23                	push   $0x23
  8010eb:	68 7c 30 80 00       	push   $0x80307c
  8010f0:	e8 2b f4 ff ff       	call   800520 <_panic>

008010f5 <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  8010f5:	f3 0f 1e fb          	endbr32 
  8010f9:	55                   	push   %ebp
  8010fa:	89 e5                	mov    %esp,%ebp
  8010fc:	57                   	push   %edi
  8010fd:	56                   	push   %esi
  8010fe:	53                   	push   %ebx
  8010ff:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  801102:	bb 00 00 00 00       	mov    $0x0,%ebx
  801107:	8b 55 08             	mov    0x8(%ebp),%edx
  80110a:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80110d:	b8 08 00 00 00       	mov    $0x8,%eax
  801112:	89 df                	mov    %ebx,%edi
  801114:	89 de                	mov    %ebx,%esi
  801116:	cd 30                	int    $0x30
	if(check && ret > 0)
  801118:	85 c0                	test   %eax,%eax
  80111a:	7f 08                	jg     801124 <sys_env_set_status+0x2f>
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  80111c:	8d 65 f4             	lea    -0xc(%ebp),%esp
  80111f:	5b                   	pop    %ebx
  801120:	5e                   	pop    %esi
  801121:	5f                   	pop    %edi
  801122:	5d                   	pop    %ebp
  801123:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  801124:	83 ec 0c             	sub    $0xc,%esp
  801127:	50                   	push   %eax
  801128:	6a 08                	push   $0x8
  80112a:	68 5f 30 80 00       	push   $0x80305f
  80112f:	6a 23                	push   $0x23
  801131:	68 7c 30 80 00       	push   $0x80307c
  801136:	e8 e5 f3 ff ff       	call   800520 <_panic>

0080113b <sys_env_set_trapframe>:

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  80113b:	f3 0f 1e fb          	endbr32 
  80113f:	55                   	push   %ebp
  801140:	89 e5                	mov    %esp,%ebp
  801142:	57                   	push   %edi
  801143:	56                   	push   %esi
  801144:	53                   	push   %ebx
  801145:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  801148:	bb 00 00 00 00       	mov    $0x0,%ebx
  80114d:	8b 55 08             	mov    0x8(%ebp),%edx
  801150:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801153:	b8 09 00 00 00       	mov    $0x9,%eax
  801158:	89 df                	mov    %ebx,%edi
  80115a:	89 de                	mov    %ebx,%esi
  80115c:	cd 30                	int    $0x30
	if(check && ret > 0)
  80115e:	85 c0                	test   %eax,%eax
  801160:	7f 08                	jg     80116a <sys_env_set_trapframe+0x2f>
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  801162:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801165:	5b                   	pop    %ebx
  801166:	5e                   	pop    %esi
  801167:	5f                   	pop    %edi
  801168:	5d                   	pop    %ebp
  801169:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  80116a:	83 ec 0c             	sub    $0xc,%esp
  80116d:	50                   	push   %eax
  80116e:	6a 09                	push   $0x9
  801170:	68 5f 30 80 00       	push   $0x80305f
  801175:	6a 23                	push   $0x23
  801177:	68 7c 30 80 00       	push   $0x80307c
  80117c:	e8 9f f3 ff ff       	call   800520 <_panic>

00801181 <sys_env_set_pgfault_upcall>:

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  801181:	f3 0f 1e fb          	endbr32 
  801185:	55                   	push   %ebp
  801186:	89 e5                	mov    %esp,%ebp
  801188:	57                   	push   %edi
  801189:	56                   	push   %esi
  80118a:	53                   	push   %ebx
  80118b:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  80118e:	bb 00 00 00 00       	mov    $0x0,%ebx
  801193:	8b 55 08             	mov    0x8(%ebp),%edx
  801196:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801199:	b8 0a 00 00 00       	mov    $0xa,%eax
  80119e:	89 df                	mov    %ebx,%edi
  8011a0:	89 de                	mov    %ebx,%esi
  8011a2:	cd 30                	int    $0x30
	if(check && ret > 0)
  8011a4:	85 c0                	test   %eax,%eax
  8011a6:	7f 08                	jg     8011b0 <sys_env_set_pgfault_upcall+0x2f>
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  8011a8:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8011ab:	5b                   	pop    %ebx
  8011ac:	5e                   	pop    %esi
  8011ad:	5f                   	pop    %edi
  8011ae:	5d                   	pop    %ebp
  8011af:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  8011b0:	83 ec 0c             	sub    $0xc,%esp
  8011b3:	50                   	push   %eax
  8011b4:	6a 0a                	push   $0xa
  8011b6:	68 5f 30 80 00       	push   $0x80305f
  8011bb:	6a 23                	push   $0x23
  8011bd:	68 7c 30 80 00       	push   $0x80307c
  8011c2:	e8 59 f3 ff ff       	call   800520 <_panic>

008011c7 <sys_ipc_try_send>:

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  8011c7:	f3 0f 1e fb          	endbr32 
  8011cb:	55                   	push   %ebp
  8011cc:	89 e5                	mov    %esp,%ebp
  8011ce:	57                   	push   %edi
  8011cf:	56                   	push   %esi
  8011d0:	53                   	push   %ebx
	asm volatile("int %1\n"
  8011d1:	8b 55 08             	mov    0x8(%ebp),%edx
  8011d4:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8011d7:	b8 0c 00 00 00       	mov    $0xc,%eax
  8011dc:	be 00 00 00 00       	mov    $0x0,%esi
  8011e1:	8b 5d 10             	mov    0x10(%ebp),%ebx
  8011e4:	8b 7d 14             	mov    0x14(%ebp),%edi
  8011e7:	cd 30                	int    $0x30
	return syscall(SYS_ipc_try_send, 0, envid, value, (uint32_t) srcva, perm, 0);
}
  8011e9:	5b                   	pop    %ebx
  8011ea:	5e                   	pop    %esi
  8011eb:	5f                   	pop    %edi
  8011ec:	5d                   	pop    %ebp
  8011ed:	c3                   	ret    

008011ee <sys_ipc_recv>:

int
sys_ipc_recv(void *dstva)
{
  8011ee:	f3 0f 1e fb          	endbr32 
  8011f2:	55                   	push   %ebp
  8011f3:	89 e5                	mov    %esp,%ebp
  8011f5:	57                   	push   %edi
  8011f6:	56                   	push   %esi
  8011f7:	53                   	push   %ebx
  8011f8:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  8011fb:	b9 00 00 00 00       	mov    $0x0,%ecx
  801200:	8b 55 08             	mov    0x8(%ebp),%edx
  801203:	b8 0d 00 00 00       	mov    $0xd,%eax
  801208:	89 cb                	mov    %ecx,%ebx
  80120a:	89 cf                	mov    %ecx,%edi
  80120c:	89 ce                	mov    %ecx,%esi
  80120e:	cd 30                	int    $0x30
	if(check && ret > 0)
  801210:	85 c0                	test   %eax,%eax
  801212:	7f 08                	jg     80121c <sys_ipc_recv+0x2e>
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  801214:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801217:	5b                   	pop    %ebx
  801218:	5e                   	pop    %esi
  801219:	5f                   	pop    %edi
  80121a:	5d                   	pop    %ebp
  80121b:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  80121c:	83 ec 0c             	sub    $0xc,%esp
  80121f:	50                   	push   %eax
  801220:	6a 0d                	push   $0xd
  801222:	68 5f 30 80 00       	push   $0x80305f
  801227:	6a 23                	push   $0x23
  801229:	68 7c 30 80 00       	push   $0x80307c
  80122e:	e8 ed f2 ff ff       	call   800520 <_panic>

00801233 <pgfault>:
// Custom page fault handler - if faulting page is copy-on-write,
// map in our own private writable copy.
//
static void
pgfault(struct UTrapframe *utf)
{
  801233:	f3 0f 1e fb          	endbr32 
  801237:	55                   	push   %ebp
  801238:	89 e5                	mov    %esp,%ebp
  80123a:	56                   	push   %esi
  80123b:	53                   	push   %ebx
  80123c:	8b 45 08             	mov    0x8(%ebp),%eax
	void *addr = (void *) utf->utf_fault_va;
  80123f:	8b 18                	mov    (%eax),%ebx
	/*
	将父进程空间中所有可以写的页表的部分全部标记为可读且COW【因此读取的时候不会进入pgfault，但是写的时候会触发pgfault】。
	而当父进程或者子进程任意一个发生了写的时候，因为页表现在都是不可写的，所以会触发异常，进入到我们设定的page fault处理例程，
	当检测到是对COW页的写操作的情况下，就可以将要写入的页的内容全部拷贝一份，重新映射。
	*/
    if (!((err & FEC_WR) && (uvpd[PDX(addr)] & PTE_P) && 
  801241:	f6 40 04 02          	testb  $0x2,0x4(%eax)
  801245:	0f 84 b2 00 00 00    	je     8012fd <pgfault+0xca>
  80124b:	89 d8                	mov    %ebx,%eax
  80124d:	c1 e8 16             	shr    $0x16,%eax
  801250:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  801257:	a8 01                	test   $0x1,%al
  801259:	0f 84 9e 00 00 00    	je     8012fd <pgfault+0xca>
			(uvpt[PGNUM(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_COW)))
  80125f:	89 d8                	mov    %ebx,%eax
  801261:	c1 e8 0c             	shr    $0xc,%eax
  801264:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
    if (!((err & FEC_WR) && (uvpd[PDX(addr)] & PTE_P) && 
  80126b:	f6 c2 01             	test   $0x1,%dl
  80126e:	0f 84 89 00 00 00    	je     8012fd <pgfault+0xca>
			(uvpt[PGNUM(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_COW)))
  801274:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
    if (!((err & FEC_WR) && (uvpd[PDX(addr)] & PTE_P) && 
  80127b:	f6 c4 08             	test   $0x8,%ah
  80127e:	74 7d                	je     8012fd <pgfault+0xca>
                panic("pgfault: it's not writable or attempt to access a non-cow page!");
	//为该进程分配新的页面。
	envid_t envid=sys_getenvid();
  801280:	e8 57 fd ff ff       	call   800fdc <sys_getenvid>
  801285:	89 c6                	mov    %eax,%esi
	r=sys_page_alloc(envid,(void*)PFTEMP,PTE_P|PTE_U|PTE_W);
  801287:	83 ec 04             	sub    $0x4,%esp
  80128a:	6a 07                	push   $0x7
  80128c:	68 00 f0 7f 00       	push   $0x7ff000
  801291:	50                   	push   %eax
  801292:	e8 8b fd ff ff       	call   801022 <sys_page_alloc>
	if(r<0){
  801297:	83 c4 10             	add    $0x10,%esp
  80129a:	85 c0                	test   %eax,%eax
  80129c:	78 73                	js     801311 <pgfault+0xde>
		 panic("pgfault: page allocation failed %e", r);
	}
	//解开了我的疑惑，为什么随着fork页空间会逐渐发生偏移。
	//迁移数据过去。
	addr=ROUNDDOWN(addr,PGSIZE);
  80129e:	81 e3 00 f0 ff ff    	and    $0xfffff000,%ebx
	//拷贝内容。
	memmove(PFTEMP,addr,PGSIZE);
  8012a4:	83 ec 04             	sub    $0x4,%esp
  8012a7:	68 00 10 00 00       	push   $0x1000
  8012ac:	53                   	push   %ebx
  8012ad:	68 00 f0 7f 00       	push   $0x7ff000
  8012b2:	e8 df fa ff ff       	call   800d96 <memmove>
	//解除和addr的映射关系。
	r=sys_page_unmap(envid,(void*)addr);
  8012b7:	83 c4 08             	add    $0x8,%esp
  8012ba:	53                   	push   %ebx
  8012bb:	56                   	push   %esi
  8012bc:	e8 ee fd ff ff       	call   8010af <sys_page_unmap>
	if(r<0)
  8012c1:	83 c4 10             	add    $0x10,%esp
  8012c4:	85 c0                	test   %eax,%eax
  8012c6:	78 5b                	js     801323 <pgfault+0xf0>
	panic("pgfault: page unmap failed %e", r);
	r=sys_page_map(envid,PFTEMP,envid,addr,PTE_P|PTE_U|PTE_W);
  8012c8:	83 ec 0c             	sub    $0xc,%esp
  8012cb:	6a 07                	push   $0x7
  8012cd:	53                   	push   %ebx
  8012ce:	56                   	push   %esi
  8012cf:	68 00 f0 7f 00       	push   $0x7ff000
  8012d4:	56                   	push   %esi
  8012d5:	e8 8f fd ff ff       	call   801069 <sys_page_map>
	if(r<0)
  8012da:	83 c4 20             	add    $0x20,%esp
  8012dd:	85 c0                	test   %eax,%eax
  8012df:	78 54                	js     801335 <pgfault+0x102>
	panic("pgfault: page map failed %e", r);
	r=sys_page_unmap(envid,PFTEMP);
  8012e1:	83 ec 08             	sub    $0x8,%esp
  8012e4:	68 00 f0 7f 00       	push   $0x7ff000
  8012e9:	56                   	push   %esi
  8012ea:	e8 c0 fd ff ff       	call   8010af <sys_page_unmap>
	if(r<0)
  8012ef:	83 c4 10             	add    $0x10,%esp
  8012f2:	85 c0                	test   %eax,%eax
  8012f4:	78 51                	js     801347 <pgfault+0x114>
	panic("pgfault: page unmap failed %e", r);
}
  8012f6:	8d 65 f8             	lea    -0x8(%ebp),%esp
  8012f9:	5b                   	pop    %ebx
  8012fa:	5e                   	pop    %esi
  8012fb:	5d                   	pop    %ebp
  8012fc:	c3                   	ret    
                panic("pgfault: it's not writable or attempt to access a non-cow page!");
  8012fd:	83 ec 04             	sub    $0x4,%esp
  801300:	68 8c 30 80 00       	push   $0x80308c
  801305:	6a 2c                	push   $0x2c
  801307:	68 3b 31 80 00       	push   $0x80313b
  80130c:	e8 0f f2 ff ff       	call   800520 <_panic>
		 panic("pgfault: page allocation failed %e", r);
  801311:	50                   	push   %eax
  801312:	68 cc 30 80 00       	push   $0x8030cc
  801317:	6a 31                	push   $0x31
  801319:	68 3b 31 80 00       	push   $0x80313b
  80131e:	e8 fd f1 ff ff       	call   800520 <_panic>
	panic("pgfault: page unmap failed %e", r);
  801323:	50                   	push   %eax
  801324:	68 46 31 80 00       	push   $0x803146
  801329:	6a 3b                	push   $0x3b
  80132b:	68 3b 31 80 00       	push   $0x80313b
  801330:	e8 eb f1 ff ff       	call   800520 <_panic>
	panic("pgfault: page map failed %e", r);
  801335:	50                   	push   %eax
  801336:	68 64 31 80 00       	push   $0x803164
  80133b:	6a 3e                	push   $0x3e
  80133d:	68 3b 31 80 00       	push   $0x80313b
  801342:	e8 d9 f1 ff ff       	call   800520 <_panic>
	panic("pgfault: page unmap failed %e", r);
  801347:	50                   	push   %eax
  801348:	68 46 31 80 00       	push   $0x803146
  80134d:	6a 41                	push   $0x41
  80134f:	68 3b 31 80 00       	push   $0x80313b
  801354:	e8 c7 f1 ff ff       	call   800520 <_panic>

00801359 <fork>:
//   Neither user exception stack should ever be marked copy-on-write,
//   so you must allocate a new page for the child's user exception stack.
//
envid_t
fork(void)
{
  801359:	f3 0f 1e fb          	endbr32 
  80135d:	55                   	push   %ebp
  80135e:	89 e5                	mov    %esp,%ebp
  801360:	57                   	push   %edi
  801361:	56                   	push   %esi
  801362:	53                   	push   %ebx
  801363:	83 ec 28             	sub    $0x28,%esp
	// LAB 4: Your code here.
	envid_t envid;
	uintptr_t pageVa;
	unsigned pn;
	//设置pgfault情况下对应处理的函数。
	set_pgfault_handler(pgfault);
  801366:	68 33 12 80 00       	push   $0x801233
  80136b:	e8 13 14 00 00       	call   802783 <set_pgfault_handler>
// This must be inlined.  Exercise for reader: why?
static inline envid_t __attribute__((always_inline))
sys_exofork(void)
{
	envid_t ret;
	asm volatile("int %2"
  801370:	b8 07 00 00 00       	mov    $0x7,%eax
  801375:	cd 30                	int    $0x30
  801377:	89 c7                	mov    %eax,%edi
  801379:	89 45 e4             	mov    %eax,-0x1c(%ebp)
	//首先需要分配一个env，env_alloc是内核态调用的，因此只能去调系统调用对应的函数来请求分配一个环境描述符。
	envid=sys_exofork();
	//分配成功
	if(envid>0){
  80137c:	83 c4 10             	add    $0x10,%esp
  80137f:	85 c0                	test   %eax,%eax
  801381:	0f 8e 9d 01 00 00    	jle    801524 <fork+0x1cb>
		//接下来应该要拷贝父进程。当然这里让我吃惊的是直接可以调用对应的宏并且并没有去请求父进程。jos系统似乎是把所有的子进程都来源于同一进程，而不是父子继承关系。
		for(pageVa=UTEXT;pageVa<USTACKTOP;pageVa+=PGSIZE){
  801387:	bb 00 00 80 00       	mov    $0x800000,%ebx
  80138c:	eb 5b                	jmp    8013e9 <fork+0x90>
			sys_page_map(0, addr, envid, addr, PTE_SYSCALL);
  80138e:	83 ec 0c             	sub    $0xc,%esp
  801391:	68 07 0e 00 00       	push   $0xe07
  801396:	56                   	push   %esi
  801397:	ff 75 e4             	pushl  -0x1c(%ebp)
  80139a:	56                   	push   %esi
  80139b:	6a 00                	push   $0x0
  80139d:	e8 c7 fc ff ff       	call   801069 <sys_page_map>
  8013a2:	83 c4 20             	add    $0x20,%esp
  8013a5:	eb 30                	jmp    8013d7 <fork+0x7e>
                panic("duppage: sys_page_map fail\n");
  8013a7:	83 ec 04             	sub    $0x4,%esp
  8013aa:	68 80 31 80 00       	push   $0x803180
  8013af:	6a 63                	push   $0x63
  8013b1:	68 3b 31 80 00       	push   $0x80313b
  8013b6:	e8 65 f1 ff ff       	call   800520 <_panic>
            r = sys_page_map(0, addr, envid, addr, PTE_U | PTE_P);
  8013bb:	83 ec 0c             	sub    $0xc,%esp
  8013be:	6a 05                	push   $0x5
  8013c0:	56                   	push   %esi
  8013c1:	ff 75 e4             	pushl  -0x1c(%ebp)
  8013c4:	56                   	push   %esi
  8013c5:	6a 00                	push   $0x0
  8013c7:	e8 9d fc ff ff       	call   801069 <sys_page_map>
            if(r < 0)
  8013cc:	83 c4 20             	add    $0x20,%esp
  8013cf:	85 c0                	test   %eax,%eax
  8013d1:	0f 88 ac 00 00 00    	js     801483 <fork+0x12a>
		for(pageVa=UTEXT;pageVa<USTACKTOP;pageVa+=PGSIZE){
  8013d7:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  8013dd:	81 fb 00 e0 bf ee    	cmp    $0xeebfe000,%ebx
  8013e3:	0f 84 ae 00 00 00    	je     801497 <fork+0x13e>
			pn=PGNUM(pageVa);
			//检查权限，挨个copy页
			if((uvpd[PDX(pageVa)]&PTE_P)&&(uvpt[pn]&PTE_P)&&(uvpt[pn]&PTE_U)){
  8013e9:	89 d8                	mov    %ebx,%eax
  8013eb:	c1 e8 16             	shr    $0x16,%eax
  8013ee:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  8013f5:	a8 01                	test   $0x1,%al
  8013f7:	74 de                	je     8013d7 <fork+0x7e>
			pn=PGNUM(pageVa);
  8013f9:	89 d8                	mov    %ebx,%eax
  8013fb:	c1 e8 0c             	shr    $0xc,%eax
			if((uvpd[PDX(pageVa)]&PTE_P)&&(uvpt[pn]&PTE_P)&&(uvpt[pn]&PTE_U)){
  8013fe:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
  801405:	f6 c2 01             	test   $0x1,%dl
  801408:	74 cd                	je     8013d7 <fork+0x7e>
  80140a:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
  801411:	f6 c2 04             	test   $0x4,%dl
  801414:	74 c1                	je     8013d7 <fork+0x7e>
        addr = (void *)((uint32_t)pn * PGSIZE);
  801416:	89 c6                	mov    %eax,%esi
  801418:	c1 e6 0c             	shl    $0xc,%esi
        pte = uvpt[pn];
  80141b:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
		if(pte&PTE_SHARE){
  801422:	f6 c4 04             	test   $0x4,%ah
  801425:	0f 85 63 ff ff ff    	jne    80138e <fork+0x35>
        else if((pte & PTE_COW) || (pte & PTE_W))
  80142b:	a9 02 08 00 00       	test   $0x802,%eax
  801430:	74 89                	je     8013bb <fork+0x62>
            r = sys_page_map(0, addr, envid, addr, PTE_COW | PTE_U | PTE_P);
  801432:	83 ec 0c             	sub    $0xc,%esp
  801435:	68 05 08 00 00       	push   $0x805
  80143a:	56                   	push   %esi
  80143b:	ff 75 e4             	pushl  -0x1c(%ebp)
  80143e:	56                   	push   %esi
  80143f:	6a 00                	push   $0x0
  801441:	e8 23 fc ff ff       	call   801069 <sys_page_map>
            if(r < 0)
  801446:	83 c4 20             	add    $0x20,%esp
  801449:	85 c0                	test   %eax,%eax
  80144b:	0f 88 56 ff ff ff    	js     8013a7 <fork+0x4e>
            r = sys_page_map(0, addr, 0, addr, PTE_COW | PTE_U | PTE_P);
  801451:	83 ec 0c             	sub    $0xc,%esp
  801454:	68 05 08 00 00       	push   $0x805
  801459:	56                   	push   %esi
  80145a:	6a 00                	push   $0x0
  80145c:	56                   	push   %esi
  80145d:	6a 00                	push   $0x0
  80145f:	e8 05 fc ff ff       	call   801069 <sys_page_map>
            if(r < 0)
  801464:	83 c4 20             	add    $0x20,%esp
  801467:	85 c0                	test   %eax,%eax
  801469:	0f 89 68 ff ff ff    	jns    8013d7 <fork+0x7e>
                panic("duppage: sys_page_map fail\n");
  80146f:	83 ec 04             	sub    $0x4,%esp
  801472:	68 80 31 80 00       	push   $0x803180
  801477:	6a 66                	push   $0x66
  801479:	68 3b 31 80 00       	push   $0x80313b
  80147e:	e8 9d f0 ff ff       	call   800520 <_panic>
                panic("duppage: sys_page_map fail\n");
  801483:	83 ec 04             	sub    $0x4,%esp
  801486:	68 80 31 80 00       	push   $0x803180
  80148b:	6a 6c                	push   $0x6c
  80148d:	68 3b 31 80 00       	push   $0x80313b
  801492:	e8 89 f0 ff ff       	call   800520 <_panic>
				duppage(envid,pn);}
			}
		//分配异常栈。
		int32_t flag=sys_page_alloc(envid,(void*)(UXSTACKTOP-PGSIZE),PTE_P|PTE_U|PTE_W);
  801497:	83 ec 04             	sub    $0x4,%esp
  80149a:	6a 07                	push   $0x7
  80149c:	68 00 f0 bf ee       	push   $0xeebff000
  8014a1:	57                   	push   %edi
  8014a2:	e8 7b fb ff ff       	call   801022 <sys_page_alloc>
		if(flag<0){
  8014a7:	83 c4 10             	add    $0x10,%esp
  8014aa:	85 c0                	test   %eax,%eax
  8014ac:	78 31                	js     8014df <fork+0x186>
			panic("panic by alloc page");
		}
		//设置对应的异常处理函数。
		extern void _pgfault_upcall(void);
		flag=sys_env_set_pgfault_upcall(envid,_pgfault_upcall);
  8014ae:	83 ec 08             	sub    $0x8,%esp
  8014b1:	68 fd 27 80 00       	push   $0x8027fd
  8014b6:	57                   	push   %edi
  8014b7:	e8 c5 fc ff ff       	call   801181 <sys_env_set_pgfault_upcall>
		if(flag<0){
  8014bc:	83 c4 10             	add    $0x10,%esp
  8014bf:	85 c0                	test   %eax,%eax
  8014c1:	78 33                	js     8014f6 <fork+0x19d>
			panic("panic by set pgfault upcall faction");
		}
		//设置子进程，等待调度。
		flag=sys_env_set_status(envid,ENV_RUNNABLE);
  8014c3:	83 ec 08             	sub    $0x8,%esp
  8014c6:	6a 02                	push   $0x2
  8014c8:	57                   	push   %edi
  8014c9:	e8 27 fc ff ff       	call   8010f5 <sys_env_set_status>
		if(flag<0){
  8014ce:	83 c4 10             	add    $0x10,%esp
  8014d1:	85 c0                	test   %eax,%eax
  8014d3:	78 38                	js     80150d <fork+0x1b4>
		//否则报错。
		panic("panic by alloc envid");
	}

	
}
  8014d5:	89 f8                	mov    %edi,%eax
  8014d7:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8014da:	5b                   	pop    %ebx
  8014db:	5e                   	pop    %esi
  8014dc:	5f                   	pop    %edi
  8014dd:	5d                   	pop    %ebp
  8014de:	c3                   	ret    
			panic("panic by alloc page");
  8014df:	83 ec 04             	sub    $0x4,%esp
  8014e2:	68 9c 31 80 00       	push   $0x80319c
  8014e7:	68 98 00 00 00       	push   $0x98
  8014ec:	68 3b 31 80 00       	push   $0x80313b
  8014f1:	e8 2a f0 ff ff       	call   800520 <_panic>
			panic("panic by set pgfault upcall faction");
  8014f6:	83 ec 04             	sub    $0x4,%esp
  8014f9:	68 f0 30 80 00       	push   $0x8030f0
  8014fe:	68 9e 00 00 00       	push   $0x9e
  801503:	68 3b 31 80 00       	push   $0x80313b
  801508:	e8 13 f0 ff ff       	call   800520 <_panic>
			panic("panic by set env status to ENV_RUNABLE");
  80150d:	83 ec 04             	sub    $0x4,%esp
  801510:	68 14 31 80 00       	push   $0x803114
  801515:	68 a3 00 00 00       	push   $0xa3
  80151a:	68 3b 31 80 00       	push   $0x80313b
  80151f:	e8 fc ef ff ff       	call   800520 <_panic>
	else if(envid==0){
  801524:	75 19                	jne    80153f <fork+0x1e6>
        thisenv = &envs[ENVX(sys_getenvid())];	//在子进程中设置thisenv为自己
  801526:	e8 b1 fa ff ff       	call   800fdc <sys_getenvid>
  80152b:	25 ff 03 00 00       	and    $0x3ff,%eax
  801530:	6b c0 7c             	imul   $0x7c,%eax,%eax
  801533:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  801538:	a3 04 50 80 00       	mov    %eax,0x805004
		return 0;
  80153d:	eb 96                	jmp    8014d5 <fork+0x17c>
		panic("panic by alloc envid");
  80153f:	83 ec 04             	sub    $0x4,%esp
  801542:	68 b0 31 80 00       	push   $0x8031b0
  801547:	68 ad 00 00 00       	push   $0xad
  80154c:	68 3b 31 80 00       	push   $0x80313b
  801551:	e8 ca ef ff ff       	call   800520 <_panic>

00801556 <sfork>:

// Challenge!
int
sfork(void)
{
  801556:	f3 0f 1e fb          	endbr32 
  80155a:	55                   	push   %ebp
  80155b:	89 e5                	mov    %esp,%ebp
  80155d:	83 ec 0c             	sub    $0xc,%esp
	panic("sfork not implemented");
  801560:	68 c5 31 80 00       	push   $0x8031c5
  801565:	68 b7 00 00 00       	push   $0xb7
  80156a:	68 3b 31 80 00       	push   $0x80313b
  80156f:	e8 ac ef ff ff       	call   800520 <_panic>

00801574 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  801574:	f3 0f 1e fb          	endbr32 
  801578:	55                   	push   %ebp
  801579:	89 e5                	mov    %esp,%ebp
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
  80157b:	8b 45 08             	mov    0x8(%ebp),%eax
  80157e:	05 00 00 00 30       	add    $0x30000000,%eax
  801583:	c1 e8 0c             	shr    $0xc,%eax
}
  801586:	5d                   	pop    %ebp
  801587:	c3                   	ret    

00801588 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  801588:	f3 0f 1e fb          	endbr32 
  80158c:	55                   	push   %ebp
  80158d:	89 e5                	mov    %esp,%ebp
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
  80158f:	8b 45 08             	mov    0x8(%ebp),%eax
  801592:	05 00 00 00 30       	add    $0x30000000,%eax
	return INDEX2DATA(fd2num(fd));
  801597:	25 00 f0 ff ff       	and    $0xfffff000,%eax
  80159c:	2d 00 00 fe 2f       	sub    $0x2ffe0000,%eax
}
  8015a1:	5d                   	pop    %ebp
  8015a2:	c3                   	ret    

008015a3 <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  8015a3:	f3 0f 1e fb          	endbr32 
  8015a7:	55                   	push   %ebp
  8015a8:	89 e5                	mov    %esp,%ebp
  8015aa:	b8 00 00 00 d0       	mov    $0xd0000000,%eax
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((uvpd[PDX(fd)] & PTE_P) == 0 || (uvpt[PGNUM(fd)] & PTE_P) == 0) {
  8015af:	89 c2                	mov    %eax,%edx
  8015b1:	c1 ea 16             	shr    $0x16,%edx
  8015b4:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  8015bb:	f6 c2 01             	test   $0x1,%dl
  8015be:	74 2d                	je     8015ed <fd_alloc+0x4a>
  8015c0:	89 c2                	mov    %eax,%edx
  8015c2:	c1 ea 0c             	shr    $0xc,%edx
  8015c5:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  8015cc:	f6 c2 01             	test   $0x1,%dl
  8015cf:	74 1c                	je     8015ed <fd_alloc+0x4a>
  8015d1:	05 00 10 00 00       	add    $0x1000,%eax
	for (i = 0; i < MAXFD; i++) {
  8015d6:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  8015db:	75 d2                	jne    8015af <fd_alloc+0xc>
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  8015dd:	8b 45 08             	mov    0x8(%ebp),%eax
  8015e0:	c7 00 00 00 00 00    	movl   $0x0,(%eax)
	return -E_MAX_OPEN;
  8015e6:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
  8015eb:	eb 0a                	jmp    8015f7 <fd_alloc+0x54>
			*fd_store = fd;
  8015ed:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8015f0:	89 01                	mov    %eax,(%ecx)
			return 0;
  8015f2:	b8 00 00 00 00       	mov    $0x0,%eax
}
  8015f7:	5d                   	pop    %ebp
  8015f8:	c3                   	ret    

008015f9 <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  8015f9:	f3 0f 1e fb          	endbr32 
  8015fd:	55                   	push   %ebp
  8015fe:	89 e5                	mov    %esp,%ebp
  801600:	8b 45 08             	mov    0x8(%ebp),%eax
	struct Fd *fd;

	if (fdnum < 0 || fdnum >= MAXFD) {
  801603:	83 f8 1f             	cmp    $0x1f,%eax
  801606:	77 30                	ja     801638 <fd_lookup+0x3f>
		if (debug)
			cprintf("[%08x] bad fd %d\n", thisenv->env_id, fdnum);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  801608:	c1 e0 0c             	shl    $0xc,%eax
  80160b:	2d 00 00 00 30       	sub    $0x30000000,%eax
	if (!(uvpd[PDX(fd)] & PTE_P) || !(uvpt[PGNUM(fd)] & PTE_P)) {
  801610:	8b 15 00 dd 7b ef    	mov    0xef7bdd00,%edx
  801616:	f6 c2 01             	test   $0x1,%dl
  801619:	74 24                	je     80163f <fd_lookup+0x46>
  80161b:	89 c2                	mov    %eax,%edx
  80161d:	c1 ea 0c             	shr    $0xc,%edx
  801620:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801627:	f6 c2 01             	test   $0x1,%dl
  80162a:	74 1a                	je     801646 <fd_lookup+0x4d>
		if (debug)
			cprintf("[%08x] closed fd %d\n", thisenv->env_id, fdnum);
		return -E_INVAL;
	}
	*fd_store = fd;
  80162c:	8b 55 0c             	mov    0xc(%ebp),%edx
  80162f:	89 02                	mov    %eax,(%edx)
	return 0;
  801631:	b8 00 00 00 00       	mov    $0x0,%eax
}
  801636:	5d                   	pop    %ebp
  801637:	c3                   	ret    
		return -E_INVAL;
  801638:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  80163d:	eb f7                	jmp    801636 <fd_lookup+0x3d>
		return -E_INVAL;
  80163f:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  801644:	eb f0                	jmp    801636 <fd_lookup+0x3d>
  801646:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  80164b:	eb e9                	jmp    801636 <fd_lookup+0x3d>

0080164d <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  80164d:	f3 0f 1e fb          	endbr32 
  801651:	55                   	push   %ebp
  801652:	89 e5                	mov    %esp,%ebp
  801654:	83 ec 08             	sub    $0x8,%esp
  801657:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80165a:	ba 58 32 80 00       	mov    $0x803258,%edx
	int i;
	for (i = 0; devtab[i]; i++)
  80165f:	b8 20 40 80 00       	mov    $0x804020,%eax
		if (devtab[i]->dev_id == dev_id) {
  801664:	39 08                	cmp    %ecx,(%eax)
  801666:	74 33                	je     80169b <dev_lookup+0x4e>
  801668:	83 c2 04             	add    $0x4,%edx
	for (i = 0; devtab[i]; i++)
  80166b:	8b 02                	mov    (%edx),%eax
  80166d:	85 c0                	test   %eax,%eax
  80166f:	75 f3                	jne    801664 <dev_lookup+0x17>
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", thisenv->env_id, dev_id);
  801671:	a1 04 50 80 00       	mov    0x805004,%eax
  801676:	8b 40 48             	mov    0x48(%eax),%eax
  801679:	83 ec 04             	sub    $0x4,%esp
  80167c:	51                   	push   %ecx
  80167d:	50                   	push   %eax
  80167e:	68 dc 31 80 00       	push   $0x8031dc
  801683:	e8 7f ef ff ff       	call   800607 <cprintf>
	*dev = 0;
  801688:	8b 45 0c             	mov    0xc(%ebp),%eax
  80168b:	c7 00 00 00 00 00    	movl   $0x0,(%eax)
	return -E_INVAL;
  801691:	83 c4 10             	add    $0x10,%esp
  801694:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801699:	c9                   	leave  
  80169a:	c3                   	ret    
			*dev = devtab[i];
  80169b:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80169e:	89 01                	mov    %eax,(%ecx)
			return 0;
  8016a0:	b8 00 00 00 00       	mov    $0x0,%eax
  8016a5:	eb f2                	jmp    801699 <dev_lookup+0x4c>

008016a7 <fd_close>:
{
  8016a7:	f3 0f 1e fb          	endbr32 
  8016ab:	55                   	push   %ebp
  8016ac:	89 e5                	mov    %esp,%ebp
  8016ae:	57                   	push   %edi
  8016af:	56                   	push   %esi
  8016b0:	53                   	push   %ebx
  8016b1:	83 ec 24             	sub    $0x24,%esp
  8016b4:	8b 75 08             	mov    0x8(%ebp),%esi
  8016b7:	8b 7d 0c             	mov    0xc(%ebp),%edi
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  8016ba:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  8016bd:	50                   	push   %eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
  8016be:	8d 86 00 00 00 30    	lea    0x30000000(%esi),%eax
  8016c4:	c1 e8 0c             	shr    $0xc,%eax
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  8016c7:	50                   	push   %eax
  8016c8:	e8 2c ff ff ff       	call   8015f9 <fd_lookup>
  8016cd:	89 c3                	mov    %eax,%ebx
  8016cf:	83 c4 10             	add    $0x10,%esp
  8016d2:	85 c0                	test   %eax,%eax
  8016d4:	78 05                	js     8016db <fd_close+0x34>
	    || fd != fd2)
  8016d6:	39 75 e4             	cmp    %esi,-0x1c(%ebp)
  8016d9:	74 16                	je     8016f1 <fd_close+0x4a>
		return (must_exist ? r : 0);
  8016db:	89 f8                	mov    %edi,%eax
  8016dd:	84 c0                	test   %al,%al
  8016df:	b8 00 00 00 00       	mov    $0x0,%eax
  8016e4:	0f 44 d8             	cmove  %eax,%ebx
}
  8016e7:	89 d8                	mov    %ebx,%eax
  8016e9:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8016ec:	5b                   	pop    %ebx
  8016ed:	5e                   	pop    %esi
  8016ee:	5f                   	pop    %edi
  8016ef:	5d                   	pop    %ebp
  8016f0:	c3                   	ret    
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  8016f1:	83 ec 08             	sub    $0x8,%esp
  8016f4:	8d 45 e0             	lea    -0x20(%ebp),%eax
  8016f7:	50                   	push   %eax
  8016f8:	ff 36                	pushl  (%esi)
  8016fa:	e8 4e ff ff ff       	call   80164d <dev_lookup>
  8016ff:	89 c3                	mov    %eax,%ebx
  801701:	83 c4 10             	add    $0x10,%esp
  801704:	85 c0                	test   %eax,%eax
  801706:	78 1a                	js     801722 <fd_close+0x7b>
		if (dev->dev_close)
  801708:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80170b:	8b 40 10             	mov    0x10(%eax),%eax
			r = 0;
  80170e:	bb 00 00 00 00       	mov    $0x0,%ebx
		if (dev->dev_close)
  801713:	85 c0                	test   %eax,%eax
  801715:	74 0b                	je     801722 <fd_close+0x7b>
			r = (*dev->dev_close)(fd);
  801717:	83 ec 0c             	sub    $0xc,%esp
  80171a:	56                   	push   %esi
  80171b:	ff d0                	call   *%eax
  80171d:	89 c3                	mov    %eax,%ebx
  80171f:	83 c4 10             	add    $0x10,%esp
	(void) sys_page_unmap(0, fd);
  801722:	83 ec 08             	sub    $0x8,%esp
  801725:	56                   	push   %esi
  801726:	6a 00                	push   $0x0
  801728:	e8 82 f9 ff ff       	call   8010af <sys_page_unmap>
	return r;
  80172d:	83 c4 10             	add    $0x10,%esp
  801730:	eb b5                	jmp    8016e7 <fd_close+0x40>

00801732 <close>:

int
close(int fdnum)
{
  801732:	f3 0f 1e fb          	endbr32 
  801736:	55                   	push   %ebp
  801737:	89 e5                	mov    %esp,%ebp
  801739:	83 ec 20             	sub    $0x20,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80173c:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80173f:	50                   	push   %eax
  801740:	ff 75 08             	pushl  0x8(%ebp)
  801743:	e8 b1 fe ff ff       	call   8015f9 <fd_lookup>
  801748:	83 c4 10             	add    $0x10,%esp
  80174b:	85 c0                	test   %eax,%eax
  80174d:	79 02                	jns    801751 <close+0x1f>
		return r;
	else
		return fd_close(fd, 1);
}
  80174f:	c9                   	leave  
  801750:	c3                   	ret    
		return fd_close(fd, 1);
  801751:	83 ec 08             	sub    $0x8,%esp
  801754:	6a 01                	push   $0x1
  801756:	ff 75 f4             	pushl  -0xc(%ebp)
  801759:	e8 49 ff ff ff       	call   8016a7 <fd_close>
  80175e:	83 c4 10             	add    $0x10,%esp
  801761:	eb ec                	jmp    80174f <close+0x1d>

00801763 <close_all>:

void
close_all(void)
{
  801763:	f3 0f 1e fb          	endbr32 
  801767:	55                   	push   %ebp
  801768:	89 e5                	mov    %esp,%ebp
  80176a:	53                   	push   %ebx
  80176b:	83 ec 04             	sub    $0x4,%esp
	int i;
	for (i = 0; i < MAXFD; i++)
  80176e:	bb 00 00 00 00       	mov    $0x0,%ebx
		close(i);
  801773:	83 ec 0c             	sub    $0xc,%esp
  801776:	53                   	push   %ebx
  801777:	e8 b6 ff ff ff       	call   801732 <close>
	for (i = 0; i < MAXFD; i++)
  80177c:	83 c3 01             	add    $0x1,%ebx
  80177f:	83 c4 10             	add    $0x10,%esp
  801782:	83 fb 20             	cmp    $0x20,%ebx
  801785:	75 ec                	jne    801773 <close_all+0x10>
}
  801787:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  80178a:	c9                   	leave  
  80178b:	c3                   	ret    

0080178c <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  80178c:	f3 0f 1e fb          	endbr32 
  801790:	55                   	push   %ebp
  801791:	89 e5                	mov    %esp,%ebp
  801793:	57                   	push   %edi
  801794:	56                   	push   %esi
  801795:	53                   	push   %ebx
  801796:	83 ec 24             	sub    $0x24,%esp
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  801799:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  80179c:	50                   	push   %eax
  80179d:	ff 75 08             	pushl  0x8(%ebp)
  8017a0:	e8 54 fe ff ff       	call   8015f9 <fd_lookup>
  8017a5:	89 c3                	mov    %eax,%ebx
  8017a7:	83 c4 10             	add    $0x10,%esp
  8017aa:	85 c0                	test   %eax,%eax
  8017ac:	0f 88 81 00 00 00    	js     801833 <dup+0xa7>
		return r;
	close(newfdnum);
  8017b2:	83 ec 0c             	sub    $0xc,%esp
  8017b5:	ff 75 0c             	pushl  0xc(%ebp)
  8017b8:	e8 75 ff ff ff       	call   801732 <close>

	newfd = INDEX2FD(newfdnum);
  8017bd:	8b 75 0c             	mov    0xc(%ebp),%esi
  8017c0:	c1 e6 0c             	shl    $0xc,%esi
  8017c3:	81 ee 00 00 00 30    	sub    $0x30000000,%esi
	ova = fd2data(oldfd);
  8017c9:	83 c4 04             	add    $0x4,%esp
  8017cc:	ff 75 e4             	pushl  -0x1c(%ebp)
  8017cf:	e8 b4 fd ff ff       	call   801588 <fd2data>
  8017d4:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  8017d6:	89 34 24             	mov    %esi,(%esp)
  8017d9:	e8 aa fd ff ff       	call   801588 <fd2data>
  8017de:	83 c4 10             	add    $0x10,%esp
  8017e1:	89 c7                	mov    %eax,%edi

	if ((uvpd[PDX(ova)] & PTE_P) && (uvpt[PGNUM(ova)] & PTE_P))
  8017e3:	89 d8                	mov    %ebx,%eax
  8017e5:	c1 e8 16             	shr    $0x16,%eax
  8017e8:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  8017ef:	a8 01                	test   $0x1,%al
  8017f1:	74 11                	je     801804 <dup+0x78>
  8017f3:	89 d8                	mov    %ebx,%eax
  8017f5:	c1 e8 0c             	shr    $0xc,%eax
  8017f8:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
  8017ff:	f6 c2 01             	test   $0x1,%dl
  801802:	75 39                	jne    80183d <dup+0xb1>
		if ((r = sys_page_map(0, ova, 0, nva, uvpt[PGNUM(ova)] & PTE_SYSCALL)) < 0)
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, uvpt[PGNUM(oldfd)] & PTE_SYSCALL)) < 0)
  801804:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  801807:	89 d0                	mov    %edx,%eax
  801809:	c1 e8 0c             	shr    $0xc,%eax
  80180c:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  801813:	83 ec 0c             	sub    $0xc,%esp
  801816:	25 07 0e 00 00       	and    $0xe07,%eax
  80181b:	50                   	push   %eax
  80181c:	56                   	push   %esi
  80181d:	6a 00                	push   $0x0
  80181f:	52                   	push   %edx
  801820:	6a 00                	push   $0x0
  801822:	e8 42 f8 ff ff       	call   801069 <sys_page_map>
  801827:	89 c3                	mov    %eax,%ebx
  801829:	83 c4 20             	add    $0x20,%esp
  80182c:	85 c0                	test   %eax,%eax
  80182e:	78 31                	js     801861 <dup+0xd5>
		goto err;

	return newfdnum;
  801830:	8b 5d 0c             	mov    0xc(%ebp),%ebx

err:
	sys_page_unmap(0, newfd);
	sys_page_unmap(0, nva);
	return r;
}
  801833:	89 d8                	mov    %ebx,%eax
  801835:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801838:	5b                   	pop    %ebx
  801839:	5e                   	pop    %esi
  80183a:	5f                   	pop    %edi
  80183b:	5d                   	pop    %ebp
  80183c:	c3                   	ret    
		if ((r = sys_page_map(0, ova, 0, nva, uvpt[PGNUM(ova)] & PTE_SYSCALL)) < 0)
  80183d:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  801844:	83 ec 0c             	sub    $0xc,%esp
  801847:	25 07 0e 00 00       	and    $0xe07,%eax
  80184c:	50                   	push   %eax
  80184d:	57                   	push   %edi
  80184e:	6a 00                	push   $0x0
  801850:	53                   	push   %ebx
  801851:	6a 00                	push   $0x0
  801853:	e8 11 f8 ff ff       	call   801069 <sys_page_map>
  801858:	89 c3                	mov    %eax,%ebx
  80185a:	83 c4 20             	add    $0x20,%esp
  80185d:	85 c0                	test   %eax,%eax
  80185f:	79 a3                	jns    801804 <dup+0x78>
	sys_page_unmap(0, newfd);
  801861:	83 ec 08             	sub    $0x8,%esp
  801864:	56                   	push   %esi
  801865:	6a 00                	push   $0x0
  801867:	e8 43 f8 ff ff       	call   8010af <sys_page_unmap>
	sys_page_unmap(0, nva);
  80186c:	83 c4 08             	add    $0x8,%esp
  80186f:	57                   	push   %edi
  801870:	6a 00                	push   $0x0
  801872:	e8 38 f8 ff ff       	call   8010af <sys_page_unmap>
	return r;
  801877:	83 c4 10             	add    $0x10,%esp
  80187a:	eb b7                	jmp    801833 <dup+0xa7>

0080187c <read>:

ssize_t
read(int fdnum, void *buf, size_t n)
{
  80187c:	f3 0f 1e fb          	endbr32 
  801880:	55                   	push   %ebp
  801881:	89 e5                	mov    %esp,%ebp
  801883:	53                   	push   %ebx
  801884:	83 ec 1c             	sub    $0x1c,%esp
  801887:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  80188a:	8d 45 f0             	lea    -0x10(%ebp),%eax
  80188d:	50                   	push   %eax
  80188e:	53                   	push   %ebx
  80188f:	e8 65 fd ff ff       	call   8015f9 <fd_lookup>
  801894:	83 c4 10             	add    $0x10,%esp
  801897:	85 c0                	test   %eax,%eax
  801899:	78 3f                	js     8018da <read+0x5e>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  80189b:	83 ec 08             	sub    $0x8,%esp
  80189e:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8018a1:	50                   	push   %eax
  8018a2:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8018a5:	ff 30                	pushl  (%eax)
  8018a7:	e8 a1 fd ff ff       	call   80164d <dev_lookup>
  8018ac:	83 c4 10             	add    $0x10,%esp
  8018af:	85 c0                	test   %eax,%eax
  8018b1:	78 27                	js     8018da <read+0x5e>
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  8018b3:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8018b6:	8b 42 08             	mov    0x8(%edx),%eax
  8018b9:	83 e0 03             	and    $0x3,%eax
  8018bc:	83 f8 01             	cmp    $0x1,%eax
  8018bf:	74 1e                	je     8018df <read+0x63>
		cprintf("[%08x] read %d -- bad mode\n", thisenv->env_id, fdnum);
		return -E_INVAL;
	}
	if (!dev->dev_read)
  8018c1:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8018c4:	8b 40 08             	mov    0x8(%eax),%eax
  8018c7:	85 c0                	test   %eax,%eax
  8018c9:	74 35                	je     801900 <read+0x84>
		return -E_NOT_SUPP;
	return (*dev->dev_read)(fd, buf, n);
  8018cb:	83 ec 04             	sub    $0x4,%esp
  8018ce:	ff 75 10             	pushl  0x10(%ebp)
  8018d1:	ff 75 0c             	pushl  0xc(%ebp)
  8018d4:	52                   	push   %edx
  8018d5:	ff d0                	call   *%eax
  8018d7:	83 c4 10             	add    $0x10,%esp
}
  8018da:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  8018dd:	c9                   	leave  
  8018de:	c3                   	ret    
		cprintf("[%08x] read %d -- bad mode\n", thisenv->env_id, fdnum);
  8018df:	a1 04 50 80 00       	mov    0x805004,%eax
  8018e4:	8b 40 48             	mov    0x48(%eax),%eax
  8018e7:	83 ec 04             	sub    $0x4,%esp
  8018ea:	53                   	push   %ebx
  8018eb:	50                   	push   %eax
  8018ec:	68 1d 32 80 00       	push   $0x80321d
  8018f1:	e8 11 ed ff ff       	call   800607 <cprintf>
		return -E_INVAL;
  8018f6:	83 c4 10             	add    $0x10,%esp
  8018f9:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  8018fe:	eb da                	jmp    8018da <read+0x5e>
		return -E_NOT_SUPP;
  801900:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801905:	eb d3                	jmp    8018da <read+0x5e>

00801907 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  801907:	f3 0f 1e fb          	endbr32 
  80190b:	55                   	push   %ebp
  80190c:	89 e5                	mov    %esp,%ebp
  80190e:	57                   	push   %edi
  80190f:	56                   	push   %esi
  801910:	53                   	push   %ebx
  801911:	83 ec 0c             	sub    $0xc,%esp
  801914:	8b 7d 08             	mov    0x8(%ebp),%edi
  801917:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;

	for (tot = 0; tot < n; tot += m) {
  80191a:	bb 00 00 00 00       	mov    $0x0,%ebx
  80191f:	eb 02                	jmp    801923 <readn+0x1c>
  801921:	01 c3                	add    %eax,%ebx
  801923:	39 f3                	cmp    %esi,%ebx
  801925:	73 21                	jae    801948 <readn+0x41>
		m = read(fdnum, (char*)buf + tot, n - tot);
  801927:	83 ec 04             	sub    $0x4,%esp
  80192a:	89 f0                	mov    %esi,%eax
  80192c:	29 d8                	sub    %ebx,%eax
  80192e:	50                   	push   %eax
  80192f:	89 d8                	mov    %ebx,%eax
  801931:	03 45 0c             	add    0xc(%ebp),%eax
  801934:	50                   	push   %eax
  801935:	57                   	push   %edi
  801936:	e8 41 ff ff ff       	call   80187c <read>
		if (m < 0)
  80193b:	83 c4 10             	add    $0x10,%esp
  80193e:	85 c0                	test   %eax,%eax
  801940:	78 04                	js     801946 <readn+0x3f>
			return m;
		if (m == 0)
  801942:	75 dd                	jne    801921 <readn+0x1a>
  801944:	eb 02                	jmp    801948 <readn+0x41>
		m = read(fdnum, (char*)buf + tot, n - tot);
  801946:	89 c3                	mov    %eax,%ebx
			break;
	}
	return tot;
}
  801948:	89 d8                	mov    %ebx,%eax
  80194a:	8d 65 f4             	lea    -0xc(%ebp),%esp
  80194d:	5b                   	pop    %ebx
  80194e:	5e                   	pop    %esi
  80194f:	5f                   	pop    %edi
  801950:	5d                   	pop    %ebp
  801951:	c3                   	ret    

00801952 <write>:

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  801952:	f3 0f 1e fb          	endbr32 
  801956:	55                   	push   %ebp
  801957:	89 e5                	mov    %esp,%ebp
  801959:	53                   	push   %ebx
  80195a:	83 ec 1c             	sub    $0x1c,%esp
  80195d:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801960:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801963:	50                   	push   %eax
  801964:	53                   	push   %ebx
  801965:	e8 8f fc ff ff       	call   8015f9 <fd_lookup>
  80196a:	83 c4 10             	add    $0x10,%esp
  80196d:	85 c0                	test   %eax,%eax
  80196f:	78 3a                	js     8019ab <write+0x59>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801971:	83 ec 08             	sub    $0x8,%esp
  801974:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801977:	50                   	push   %eax
  801978:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80197b:	ff 30                	pushl  (%eax)
  80197d:	e8 cb fc ff ff       	call   80164d <dev_lookup>
  801982:	83 c4 10             	add    $0x10,%esp
  801985:	85 c0                	test   %eax,%eax
  801987:	78 22                	js     8019ab <write+0x59>
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  801989:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80198c:	f6 40 08 03          	testb  $0x3,0x8(%eax)
  801990:	74 1e                	je     8019b0 <write+0x5e>
		return -E_INVAL;
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  801992:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801995:	8b 52 0c             	mov    0xc(%edx),%edx
  801998:	85 d2                	test   %edx,%edx
  80199a:	74 35                	je     8019d1 <write+0x7f>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  80199c:	83 ec 04             	sub    $0x4,%esp
  80199f:	ff 75 10             	pushl  0x10(%ebp)
  8019a2:	ff 75 0c             	pushl  0xc(%ebp)
  8019a5:	50                   	push   %eax
  8019a6:	ff d2                	call   *%edx
  8019a8:	83 c4 10             	add    $0x10,%esp
}
  8019ab:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  8019ae:	c9                   	leave  
  8019af:	c3                   	ret    
		cprintf("[%08x] write %d -- bad mode\n", thisenv->env_id, fdnum);
  8019b0:	a1 04 50 80 00       	mov    0x805004,%eax
  8019b5:	8b 40 48             	mov    0x48(%eax),%eax
  8019b8:	83 ec 04             	sub    $0x4,%esp
  8019bb:	53                   	push   %ebx
  8019bc:	50                   	push   %eax
  8019bd:	68 39 32 80 00       	push   $0x803239
  8019c2:	e8 40 ec ff ff       	call   800607 <cprintf>
		return -E_INVAL;
  8019c7:	83 c4 10             	add    $0x10,%esp
  8019ca:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  8019cf:	eb da                	jmp    8019ab <write+0x59>
		return -E_NOT_SUPP;
  8019d1:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8019d6:	eb d3                	jmp    8019ab <write+0x59>

008019d8 <seek>:

int
seek(int fdnum, off_t offset)
{
  8019d8:	f3 0f 1e fb          	endbr32 
  8019dc:	55                   	push   %ebp
  8019dd:	89 e5                	mov    %esp,%ebp
  8019df:	83 ec 20             	sub    $0x20,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8019e2:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8019e5:	50                   	push   %eax
  8019e6:	ff 75 08             	pushl  0x8(%ebp)
  8019e9:	e8 0b fc ff ff       	call   8015f9 <fd_lookup>
  8019ee:	83 c4 10             	add    $0x10,%esp
  8019f1:	85 c0                	test   %eax,%eax
  8019f3:	78 0e                	js     801a03 <seek+0x2b>
		return r;
	fd->fd_offset = offset;
  8019f5:	8b 55 0c             	mov    0xc(%ebp),%edx
  8019f8:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8019fb:	89 50 04             	mov    %edx,0x4(%eax)
	return 0;
  8019fe:	b8 00 00 00 00       	mov    $0x0,%eax
}
  801a03:	c9                   	leave  
  801a04:	c3                   	ret    

00801a05 <ftruncate>:

int
ftruncate(int fdnum, off_t newsize)
{
  801a05:	f3 0f 1e fb          	endbr32 
  801a09:	55                   	push   %ebp
  801a0a:	89 e5                	mov    %esp,%ebp
  801a0c:	53                   	push   %ebx
  801a0d:	83 ec 1c             	sub    $0x1c,%esp
  801a10:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801a13:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801a16:	50                   	push   %eax
  801a17:	53                   	push   %ebx
  801a18:	e8 dc fb ff ff       	call   8015f9 <fd_lookup>
  801a1d:	83 c4 10             	add    $0x10,%esp
  801a20:	85 c0                	test   %eax,%eax
  801a22:	78 37                	js     801a5b <ftruncate+0x56>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801a24:	83 ec 08             	sub    $0x8,%esp
  801a27:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801a2a:	50                   	push   %eax
  801a2b:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801a2e:	ff 30                	pushl  (%eax)
  801a30:	e8 18 fc ff ff       	call   80164d <dev_lookup>
  801a35:	83 c4 10             	add    $0x10,%esp
  801a38:	85 c0                	test   %eax,%eax
  801a3a:	78 1f                	js     801a5b <ftruncate+0x56>
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  801a3c:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801a3f:	f6 40 08 03          	testb  $0x3,0x8(%eax)
  801a43:	74 1b                	je     801a60 <ftruncate+0x5b>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			thisenv->env_id, fdnum);
		return -E_INVAL;
	}
	if (!dev->dev_trunc)
  801a45:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801a48:	8b 52 18             	mov    0x18(%edx),%edx
  801a4b:	85 d2                	test   %edx,%edx
  801a4d:	74 32                	je     801a81 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  801a4f:	83 ec 08             	sub    $0x8,%esp
  801a52:	ff 75 0c             	pushl  0xc(%ebp)
  801a55:	50                   	push   %eax
  801a56:	ff d2                	call   *%edx
  801a58:	83 c4 10             	add    $0x10,%esp
}
  801a5b:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  801a5e:	c9                   	leave  
  801a5f:	c3                   	ret    
			thisenv->env_id, fdnum);
  801a60:	a1 04 50 80 00       	mov    0x805004,%eax
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  801a65:	8b 40 48             	mov    0x48(%eax),%eax
  801a68:	83 ec 04             	sub    $0x4,%esp
  801a6b:	53                   	push   %ebx
  801a6c:	50                   	push   %eax
  801a6d:	68 fc 31 80 00       	push   $0x8031fc
  801a72:	e8 90 eb ff ff       	call   800607 <cprintf>
		return -E_INVAL;
  801a77:	83 c4 10             	add    $0x10,%esp
  801a7a:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  801a7f:	eb da                	jmp    801a5b <ftruncate+0x56>
		return -E_NOT_SUPP;
  801a81:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801a86:	eb d3                	jmp    801a5b <ftruncate+0x56>

00801a88 <fstat>:

int
fstat(int fdnum, struct Stat *stat)
{
  801a88:	f3 0f 1e fb          	endbr32 
  801a8c:	55                   	push   %ebp
  801a8d:	89 e5                	mov    %esp,%ebp
  801a8f:	53                   	push   %ebx
  801a90:	83 ec 1c             	sub    $0x1c,%esp
  801a93:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801a96:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801a99:	50                   	push   %eax
  801a9a:	ff 75 08             	pushl  0x8(%ebp)
  801a9d:	e8 57 fb ff ff       	call   8015f9 <fd_lookup>
  801aa2:	83 c4 10             	add    $0x10,%esp
  801aa5:	85 c0                	test   %eax,%eax
  801aa7:	78 4b                	js     801af4 <fstat+0x6c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801aa9:	83 ec 08             	sub    $0x8,%esp
  801aac:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801aaf:	50                   	push   %eax
  801ab0:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801ab3:	ff 30                	pushl  (%eax)
  801ab5:	e8 93 fb ff ff       	call   80164d <dev_lookup>
  801aba:	83 c4 10             	add    $0x10,%esp
  801abd:	85 c0                	test   %eax,%eax
  801abf:	78 33                	js     801af4 <fstat+0x6c>
		return r;
	if (!dev->dev_stat)
  801ac1:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801ac4:	83 78 14 00          	cmpl   $0x0,0x14(%eax)
  801ac8:	74 2f                	je     801af9 <fstat+0x71>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  801aca:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  801acd:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  801ad4:	00 00 00 
	stat->st_isdir = 0;
  801ad7:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  801ade:	00 00 00 
	stat->st_dev = dev;
  801ae1:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  801ae7:	83 ec 08             	sub    $0x8,%esp
  801aea:	53                   	push   %ebx
  801aeb:	ff 75 f0             	pushl  -0x10(%ebp)
  801aee:	ff 50 14             	call   *0x14(%eax)
  801af1:	83 c4 10             	add    $0x10,%esp
}
  801af4:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  801af7:	c9                   	leave  
  801af8:	c3                   	ret    
		return -E_NOT_SUPP;
  801af9:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801afe:	eb f4                	jmp    801af4 <fstat+0x6c>

00801b00 <stat>:

int
stat(const char *path, struct Stat *stat)
{
  801b00:	f3 0f 1e fb          	endbr32 
  801b04:	55                   	push   %ebp
  801b05:	89 e5                	mov    %esp,%ebp
  801b07:	56                   	push   %esi
  801b08:	53                   	push   %ebx
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  801b09:	83 ec 08             	sub    $0x8,%esp
  801b0c:	6a 00                	push   $0x0
  801b0e:	ff 75 08             	pushl  0x8(%ebp)
  801b11:	e8 fb 01 00 00       	call   801d11 <open>
  801b16:	89 c3                	mov    %eax,%ebx
  801b18:	83 c4 10             	add    $0x10,%esp
  801b1b:	85 c0                	test   %eax,%eax
  801b1d:	78 1b                	js     801b3a <stat+0x3a>
		return fd;
	r = fstat(fd, stat);
  801b1f:	83 ec 08             	sub    $0x8,%esp
  801b22:	ff 75 0c             	pushl  0xc(%ebp)
  801b25:	50                   	push   %eax
  801b26:	e8 5d ff ff ff       	call   801a88 <fstat>
  801b2b:	89 c6                	mov    %eax,%esi
	close(fd);
  801b2d:	89 1c 24             	mov    %ebx,(%esp)
  801b30:	e8 fd fb ff ff       	call   801732 <close>
	return r;
  801b35:	83 c4 10             	add    $0x10,%esp
  801b38:	89 f3                	mov    %esi,%ebx
}
  801b3a:	89 d8                	mov    %ebx,%eax
  801b3c:	8d 65 f8             	lea    -0x8(%ebp),%esp
  801b3f:	5b                   	pop    %ebx
  801b40:	5e                   	pop    %esi
  801b41:	5d                   	pop    %ebp
  801b42:	c3                   	ret    

00801b43 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  801b43:	55                   	push   %ebp
  801b44:	89 e5                	mov    %esp,%ebp
  801b46:	56                   	push   %esi
  801b47:	53                   	push   %ebx
  801b48:	89 c6                	mov    %eax,%esi
  801b4a:	89 d3                	mov    %edx,%ebx
	static envid_t fsenv;
	if (fsenv == 0)
  801b4c:	83 3d 00 50 80 00 00 	cmpl   $0x0,0x805000
  801b53:	74 27                	je     801b7c <fsipc+0x39>
	static_assert(sizeof(fsipcbuf) == PGSIZE);

	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", thisenv->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(fsenv, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  801b55:	6a 07                	push   $0x7
  801b57:	68 00 60 80 00       	push   $0x806000
  801b5c:	56                   	push   %esi
  801b5d:	ff 35 00 50 80 00    	pushl  0x805000
  801b63:	e8 3d 0d 00 00       	call   8028a5 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  801b68:	83 c4 0c             	add    $0xc,%esp
  801b6b:	6a 00                	push   $0x0
  801b6d:	53                   	push   %ebx
  801b6e:	6a 00                	push   $0x0
  801b70:	e8 af 0c 00 00       	call   802824 <ipc_recv>
}
  801b75:	8d 65 f8             	lea    -0x8(%ebp),%esp
  801b78:	5b                   	pop    %ebx
  801b79:	5e                   	pop    %esi
  801b7a:	5d                   	pop    %ebp
  801b7b:	c3                   	ret    
		fsenv = ipc_find_env(ENV_TYPE_FS);
  801b7c:	83 ec 0c             	sub    $0xc,%esp
  801b7f:	6a 01                	push   $0x1
  801b81:	e8 77 0d 00 00       	call   8028fd <ipc_find_env>
  801b86:	a3 00 50 80 00       	mov    %eax,0x805000
  801b8b:	83 c4 10             	add    $0x10,%esp
  801b8e:	eb c5                	jmp    801b55 <fsipc+0x12>

00801b90 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  801b90:	f3 0f 1e fb          	endbr32 
  801b94:	55                   	push   %ebp
  801b95:	89 e5                	mov    %esp,%ebp
  801b97:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  801b9a:	8b 45 08             	mov    0x8(%ebp),%eax
  801b9d:	8b 40 0c             	mov    0xc(%eax),%eax
  801ba0:	a3 00 60 80 00       	mov    %eax,0x806000
	fsipcbuf.set_size.req_size = newsize;
  801ba5:	8b 45 0c             	mov    0xc(%ebp),%eax
  801ba8:	a3 04 60 80 00       	mov    %eax,0x806004
	return fsipc(FSREQ_SET_SIZE, NULL);
  801bad:	ba 00 00 00 00       	mov    $0x0,%edx
  801bb2:	b8 02 00 00 00       	mov    $0x2,%eax
  801bb7:	e8 87 ff ff ff       	call   801b43 <fsipc>
}
  801bbc:	c9                   	leave  
  801bbd:	c3                   	ret    

00801bbe <devfile_flush>:
{
  801bbe:	f3 0f 1e fb          	endbr32 
  801bc2:	55                   	push   %ebp
  801bc3:	89 e5                	mov    %esp,%ebp
  801bc5:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  801bc8:	8b 45 08             	mov    0x8(%ebp),%eax
  801bcb:	8b 40 0c             	mov    0xc(%eax),%eax
  801bce:	a3 00 60 80 00       	mov    %eax,0x806000
	return fsipc(FSREQ_FLUSH, NULL);
  801bd3:	ba 00 00 00 00       	mov    $0x0,%edx
  801bd8:	b8 06 00 00 00       	mov    $0x6,%eax
  801bdd:	e8 61 ff ff ff       	call   801b43 <fsipc>
}
  801be2:	c9                   	leave  
  801be3:	c3                   	ret    

00801be4 <devfile_stat>:
{
  801be4:	f3 0f 1e fb          	endbr32 
  801be8:	55                   	push   %ebp
  801be9:	89 e5                	mov    %esp,%ebp
  801beb:	53                   	push   %ebx
  801bec:	83 ec 04             	sub    $0x4,%esp
  801bef:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  801bf2:	8b 45 08             	mov    0x8(%ebp),%eax
  801bf5:	8b 40 0c             	mov    0xc(%eax),%eax
  801bf8:	a3 00 60 80 00       	mov    %eax,0x806000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  801bfd:	ba 00 00 00 00       	mov    $0x0,%edx
  801c02:	b8 05 00 00 00       	mov    $0x5,%eax
  801c07:	e8 37 ff ff ff       	call   801b43 <fsipc>
  801c0c:	85 c0                	test   %eax,%eax
  801c0e:	78 2c                	js     801c3c <devfile_stat+0x58>
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  801c10:	83 ec 08             	sub    $0x8,%esp
  801c13:	68 00 60 80 00       	push   $0x806000
  801c18:	53                   	push   %ebx
  801c19:	e8 c2 ef ff ff       	call   800be0 <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  801c1e:	a1 80 60 80 00       	mov    0x806080,%eax
  801c23:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  801c29:	a1 84 60 80 00       	mov    0x806084,%eax
  801c2e:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
	return 0;
  801c34:	83 c4 10             	add    $0x10,%esp
  801c37:	b8 00 00 00 00       	mov    $0x0,%eax
}
  801c3c:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  801c3f:	c9                   	leave  
  801c40:	c3                   	ret    

00801c41 <devfile_write>:
{
  801c41:	f3 0f 1e fb          	endbr32 
  801c45:	55                   	push   %ebp
  801c46:	89 e5                	mov    %esp,%ebp
  801c48:	83 ec 0c             	sub    $0xc,%esp
  801c4b:	8b 45 10             	mov    0x10(%ebp),%eax
  801c4e:	3d f8 0f 00 00       	cmp    $0xff8,%eax
  801c53:	ba f8 0f 00 00       	mov    $0xff8,%edx
  801c58:	0f 47 c2             	cmova  %edx,%eax
	fsipcbuf.write.req_fileid = fd->fd_file.id;
  801c5b:	8b 55 08             	mov    0x8(%ebp),%edx
  801c5e:	8b 52 0c             	mov    0xc(%edx),%edx
  801c61:	89 15 00 60 80 00    	mov    %edx,0x806000
	fsipcbuf.write.req_n = n;
  801c67:	a3 04 60 80 00       	mov    %eax,0x806004
	memmove(fsipcbuf.write.req_buf, buf, n);
  801c6c:	50                   	push   %eax
  801c6d:	ff 75 0c             	pushl  0xc(%ebp)
  801c70:	68 08 60 80 00       	push   $0x806008
  801c75:	e8 1c f1 ff ff       	call   800d96 <memmove>
	return fsipc(FSREQ_WRITE, NULL);}
  801c7a:	ba 00 00 00 00       	mov    $0x0,%edx
  801c7f:	b8 04 00 00 00       	mov    $0x4,%eax
  801c84:	e8 ba fe ff ff       	call   801b43 <fsipc>
  801c89:	c9                   	leave  
  801c8a:	c3                   	ret    

00801c8b <devfile_read>:
{
  801c8b:	f3 0f 1e fb          	endbr32 
  801c8f:	55                   	push   %ebp
  801c90:	89 e5                	mov    %esp,%ebp
  801c92:	56                   	push   %esi
  801c93:	53                   	push   %ebx
  801c94:	8b 75 10             	mov    0x10(%ebp),%esi
	fsipcbuf.read.req_fileid = fd->fd_file.id;
  801c97:	8b 45 08             	mov    0x8(%ebp),%eax
  801c9a:	8b 40 0c             	mov    0xc(%eax),%eax
  801c9d:	a3 00 60 80 00       	mov    %eax,0x806000
	fsipcbuf.read.req_n = n;
  801ca2:	89 35 04 60 80 00    	mov    %esi,0x806004
	if ((r = fsipc(FSREQ_READ, NULL)) < 0)
  801ca8:	ba 00 00 00 00       	mov    $0x0,%edx
  801cad:	b8 03 00 00 00       	mov    $0x3,%eax
  801cb2:	e8 8c fe ff ff       	call   801b43 <fsipc>
  801cb7:	89 c3                	mov    %eax,%ebx
  801cb9:	85 c0                	test   %eax,%eax
  801cbb:	78 1f                	js     801cdc <devfile_read+0x51>
	assert(r <= n);
  801cbd:	39 f0                	cmp    %esi,%eax
  801cbf:	77 24                	ja     801ce5 <devfile_read+0x5a>
	assert(r <= PGSIZE);
  801cc1:	3d 00 10 00 00       	cmp    $0x1000,%eax
  801cc6:	7f 33                	jg     801cfb <devfile_read+0x70>
	memmove(buf, fsipcbuf.readRet.ret_buf, r);
  801cc8:	83 ec 04             	sub    $0x4,%esp
  801ccb:	50                   	push   %eax
  801ccc:	68 00 60 80 00       	push   $0x806000
  801cd1:	ff 75 0c             	pushl  0xc(%ebp)
  801cd4:	e8 bd f0 ff ff       	call   800d96 <memmove>
	return r;
  801cd9:	83 c4 10             	add    $0x10,%esp
}
  801cdc:	89 d8                	mov    %ebx,%eax
  801cde:	8d 65 f8             	lea    -0x8(%ebp),%esp
  801ce1:	5b                   	pop    %ebx
  801ce2:	5e                   	pop    %esi
  801ce3:	5d                   	pop    %ebp
  801ce4:	c3                   	ret    
	assert(r <= n);
  801ce5:	68 68 32 80 00       	push   $0x803268
  801cea:	68 6f 32 80 00       	push   $0x80326f
  801cef:	6a 7c                	push   $0x7c
  801cf1:	68 84 32 80 00       	push   $0x803284
  801cf6:	e8 25 e8 ff ff       	call   800520 <_panic>
	assert(r <= PGSIZE);
  801cfb:	68 8f 32 80 00       	push   $0x80328f
  801d00:	68 6f 32 80 00       	push   $0x80326f
  801d05:	6a 7d                	push   $0x7d
  801d07:	68 84 32 80 00       	push   $0x803284
  801d0c:	e8 0f e8 ff ff       	call   800520 <_panic>

00801d11 <open>:
{
  801d11:	f3 0f 1e fb          	endbr32 
  801d15:	55                   	push   %ebp
  801d16:	89 e5                	mov    %esp,%ebp
  801d18:	56                   	push   %esi
  801d19:	53                   	push   %ebx
  801d1a:	83 ec 1c             	sub    $0x1c,%esp
  801d1d:	8b 75 08             	mov    0x8(%ebp),%esi
	if (strlen(path) >= MAXPATHLEN)
  801d20:	56                   	push   %esi
  801d21:	e8 77 ee ff ff       	call   800b9d <strlen>
  801d26:	83 c4 10             	add    $0x10,%esp
  801d29:	3d ff 03 00 00       	cmp    $0x3ff,%eax
  801d2e:	7f 6c                	jg     801d9c <open+0x8b>
	if ((r = fd_alloc(&fd)) < 0)
  801d30:	83 ec 0c             	sub    $0xc,%esp
  801d33:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801d36:	50                   	push   %eax
  801d37:	e8 67 f8 ff ff       	call   8015a3 <fd_alloc>
  801d3c:	89 c3                	mov    %eax,%ebx
  801d3e:	83 c4 10             	add    $0x10,%esp
  801d41:	85 c0                	test   %eax,%eax
  801d43:	78 3c                	js     801d81 <open+0x70>
	strcpy(fsipcbuf.open.req_path, path);
  801d45:	83 ec 08             	sub    $0x8,%esp
  801d48:	56                   	push   %esi
  801d49:	68 00 60 80 00       	push   $0x806000
  801d4e:	e8 8d ee ff ff       	call   800be0 <strcpy>
	fsipcbuf.open.req_omode = mode;
  801d53:	8b 45 0c             	mov    0xc(%ebp),%eax
  801d56:	a3 00 64 80 00       	mov    %eax,0x806400
	if ((r = fsipc(FSREQ_OPEN, fd)) < 0) {
  801d5b:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801d5e:	b8 01 00 00 00       	mov    $0x1,%eax
  801d63:	e8 db fd ff ff       	call   801b43 <fsipc>
  801d68:	89 c3                	mov    %eax,%ebx
  801d6a:	83 c4 10             	add    $0x10,%esp
  801d6d:	85 c0                	test   %eax,%eax
  801d6f:	78 19                	js     801d8a <open+0x79>
	return fd2num(fd);
  801d71:	83 ec 0c             	sub    $0xc,%esp
  801d74:	ff 75 f4             	pushl  -0xc(%ebp)
  801d77:	e8 f8 f7 ff ff       	call   801574 <fd2num>
  801d7c:	89 c3                	mov    %eax,%ebx
  801d7e:	83 c4 10             	add    $0x10,%esp
}
  801d81:	89 d8                	mov    %ebx,%eax
  801d83:	8d 65 f8             	lea    -0x8(%ebp),%esp
  801d86:	5b                   	pop    %ebx
  801d87:	5e                   	pop    %esi
  801d88:	5d                   	pop    %ebp
  801d89:	c3                   	ret    
		fd_close(fd, 0);
  801d8a:	83 ec 08             	sub    $0x8,%esp
  801d8d:	6a 00                	push   $0x0
  801d8f:	ff 75 f4             	pushl  -0xc(%ebp)
  801d92:	e8 10 f9 ff ff       	call   8016a7 <fd_close>
		return r;
  801d97:	83 c4 10             	add    $0x10,%esp
  801d9a:	eb e5                	jmp    801d81 <open+0x70>
		return -E_BAD_PATH;
  801d9c:	bb f4 ff ff ff       	mov    $0xfffffff4,%ebx
  801da1:	eb de                	jmp    801d81 <open+0x70>

00801da3 <sync>:


// Synchronize disk with buffer cache
int
sync(void)
{
  801da3:	f3 0f 1e fb          	endbr32 
  801da7:	55                   	push   %ebp
  801da8:	89 e5                	mov    %esp,%ebp
  801daa:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  801dad:	ba 00 00 00 00       	mov    $0x0,%edx
  801db2:	b8 08 00 00 00       	mov    $0x8,%eax
  801db7:	e8 87 fd ff ff       	call   801b43 <fsipc>
}
  801dbc:	c9                   	leave  
  801dbd:	c3                   	ret    

00801dbe <spawn>:
// argv: pointer to null-terminated array of pointers to strings,
// 	 which will be passed to the child as its command-line arguments.
// Returns child envid on success, < 0 on failure.
int
spawn(const char *prog, const char **argv)
{
  801dbe:	f3 0f 1e fb          	endbr32 
  801dc2:	55                   	push   %ebp
  801dc3:	89 e5                	mov    %esp,%ebp
  801dc5:	57                   	push   %edi
  801dc6:	56                   	push   %esi
  801dc7:	53                   	push   %ebx
  801dc8:	81 ec 94 02 00 00    	sub    $0x294,%esp
	//   - Call sys_env_set_trapframe(child, &child_tf) to set up the
	//     correct initial eip and esp values in the child.
	//
	//   - Start the child process running with sys_env_set_status().

	if ((r = open(prog, O_RDONLY)) < 0)
  801dce:	6a 00                	push   $0x0
  801dd0:	ff 75 08             	pushl  0x8(%ebp)
  801dd3:	e8 39 ff ff ff       	call   801d11 <open>
  801dd8:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
  801dde:	83 c4 10             	add    $0x10,%esp
  801de1:	85 c0                	test   %eax,%eax
  801de3:	0f 88 e5 04 00 00    	js     8022ce <spawn+0x510>
  801de9:	89 c1                	mov    %eax,%ecx
		return r;
	fd = r;

	// Read elf header
	elf = (struct Elf*) elf_buf;
	if (readn(fd, elf_buf, sizeof(elf_buf)) != sizeof(elf_buf)
  801deb:	83 ec 04             	sub    $0x4,%esp
  801dee:	68 00 02 00 00       	push   $0x200
  801df3:	8d 85 e8 fd ff ff    	lea    -0x218(%ebp),%eax
  801df9:	50                   	push   %eax
  801dfa:	51                   	push   %ecx
  801dfb:	e8 07 fb ff ff       	call   801907 <readn>
  801e00:	83 c4 10             	add    $0x10,%esp
  801e03:	3d 00 02 00 00       	cmp    $0x200,%eax
  801e08:	75 7e                	jne    801e88 <spawn+0xca>
	    || elf->e_magic != ELF_MAGIC) {
  801e0a:	81 bd e8 fd ff ff 7f 	cmpl   $0x464c457f,-0x218(%ebp)
  801e11:	45 4c 46 
  801e14:	75 72                	jne    801e88 <spawn+0xca>
  801e16:	b8 07 00 00 00       	mov    $0x7,%eax
  801e1b:	cd 30                	int    $0x30
  801e1d:	89 85 74 fd ff ff    	mov    %eax,-0x28c(%ebp)
  801e23:	89 85 88 fd ff ff    	mov    %eax,-0x278(%ebp)
		cprintf("elf magic %08x want %08x\n", elf->e_magic, ELF_MAGIC);
		return -E_NOT_EXEC;
	}

	// Create new child environment
	if ((r = sys_exofork()) < 0)
  801e29:	85 c0                	test   %eax,%eax
  801e2b:	0f 88 91 04 00 00    	js     8022c2 <spawn+0x504>
		return r;
	child = r;

	// Set up trap frame, including initial stack.
	child_tf = envs[ENVX(child)].env_tf;
  801e31:	25 ff 03 00 00       	and    $0x3ff,%eax
  801e36:	6b f0 7c             	imul   $0x7c,%eax,%esi
  801e39:	81 c6 00 00 c0 ee    	add    $0xeec00000,%esi
  801e3f:	8d bd a4 fd ff ff    	lea    -0x25c(%ebp),%edi
  801e45:	b9 11 00 00 00       	mov    $0x11,%ecx
  801e4a:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	child_tf.tf_eip = elf->e_entry;
  801e4c:	8b 85 00 fe ff ff    	mov    -0x200(%ebp),%eax
  801e52:	89 85 d4 fd ff ff    	mov    %eax,-0x22c(%ebp)
	uintptr_t *argv_store;

	// Count the number of arguments (argc)
	// and the total amount of space needed for strings (string_size).
	string_size = 0;
	for (argc = 0; argv[argc] != 0; argc++)
  801e58:	bb 00 00 00 00       	mov    $0x0,%ebx
	string_size = 0;
  801e5d:	be 00 00 00 00       	mov    $0x0,%esi
  801e62:	8b 7d 0c             	mov    0xc(%ebp),%edi
  801e65:	8d 0c 9d 00 00 00 00 	lea    0x0(,%ebx,4),%ecx
	for (argc = 0; argv[argc] != 0; argc++)
  801e6c:	8b 04 9f             	mov    (%edi,%ebx,4),%eax
  801e6f:	85 c0                	test   %eax,%eax
  801e71:	74 4d                	je     801ec0 <spawn+0x102>
		string_size += strlen(argv[argc]) + 1;
  801e73:	83 ec 0c             	sub    $0xc,%esp
  801e76:	50                   	push   %eax
  801e77:	e8 21 ed ff ff       	call   800b9d <strlen>
  801e7c:	8d 74 06 01          	lea    0x1(%esi,%eax,1),%esi
	for (argc = 0; argv[argc] != 0; argc++)
  801e80:	83 c3 01             	add    $0x1,%ebx
  801e83:	83 c4 10             	add    $0x10,%esp
  801e86:	eb dd                	jmp    801e65 <spawn+0xa7>
		close(fd);
  801e88:	83 ec 0c             	sub    $0xc,%esp
  801e8b:	ff b5 94 fd ff ff    	pushl  -0x26c(%ebp)
  801e91:	e8 9c f8 ff ff       	call   801732 <close>
		cprintf("elf magic %08x want %08x\n", elf->e_magic, ELF_MAGIC);
  801e96:	83 c4 0c             	add    $0xc,%esp
  801e99:	68 7f 45 4c 46       	push   $0x464c457f
  801e9e:	ff b5 e8 fd ff ff    	pushl  -0x218(%ebp)
  801ea4:	68 9b 32 80 00       	push   $0x80329b
  801ea9:	e8 59 e7 ff ff       	call   800607 <cprintf>
		return -E_NOT_EXEC;
  801eae:	83 c4 10             	add    $0x10,%esp
  801eb1:	c7 85 94 fd ff ff f2 	movl   $0xfffffff2,-0x26c(%ebp)
  801eb8:	ff ff ff 
  801ebb:	e9 0e 04 00 00       	jmp    8022ce <spawn+0x510>
  801ec0:	89 9d 84 fd ff ff    	mov    %ebx,-0x27c(%ebp)
  801ec6:	89 8d 80 fd ff ff    	mov    %ecx,-0x280(%ebp)
	// Determine where to place the strings and the argv array.
	// Set up pointers into the temporary page 'UTEMP'; we'll map a page
	// there later, then remap that page into the child environment
	// at (USTACKTOP - PGSIZE).
	// strings is the topmost thing on the stack.
	string_store = (char*) UTEMP + PGSIZE - string_size;
  801ecc:	bf 00 10 40 00       	mov    $0x401000,%edi
  801ed1:	29 f7                	sub    %esi,%edi
	// argv is below that.  There's one argument pointer per argument, plus
	// a null pointer.
	argv_store = (uintptr_t*) (ROUNDDOWN(string_store, 4) - 4 * (argc + 1));
  801ed3:	89 fa                	mov    %edi,%edx
  801ed5:	83 e2 fc             	and    $0xfffffffc,%edx
  801ed8:	8d 04 9d 04 00 00 00 	lea    0x4(,%ebx,4),%eax
  801edf:	29 c2                	sub    %eax,%edx
  801ee1:	89 95 90 fd ff ff    	mov    %edx,-0x270(%ebp)

	// Make sure that argv, strings, and the 2 words that hold 'argc'
	// and 'argv' themselves will all fit in a single stack page.
	if ((void*) (argv_store - 2) < (void*) UTEMP)
  801ee7:	8d 42 f8             	lea    -0x8(%edx),%eax
  801eea:	3d ff ff 3f 00       	cmp    $0x3fffff,%eax
  801eef:	0f 86 fc 03 00 00    	jbe    8022f1 <spawn+0x533>
		return -E_NO_MEM;

	// Allocate the single stack page at UTEMP.
	if ((r = sys_page_alloc(0, (void*) UTEMP, PTE_P|PTE_U|PTE_W)) < 0)
  801ef5:	83 ec 04             	sub    $0x4,%esp
  801ef8:	6a 07                	push   $0x7
  801efa:	68 00 00 40 00       	push   $0x400000
  801eff:	6a 00                	push   $0x0
  801f01:	e8 1c f1 ff ff       	call   801022 <sys_page_alloc>
  801f06:	83 c4 10             	add    $0x10,%esp
  801f09:	85 c0                	test   %eax,%eax
  801f0b:	0f 88 e5 03 00 00    	js     8022f6 <spawn+0x538>
	//	  (Again, argv should use an address valid in the child's
	//	  environment.)
	//
	//	* Set *init_esp to the initial stack pointer for the child,
	//	  (Again, use an address valid in the child's environment.)
	for (i = 0; i < argc; i++) {
  801f11:	be 00 00 00 00       	mov    $0x0,%esi
  801f16:	89 9d 8c fd ff ff    	mov    %ebx,-0x274(%ebp)
  801f1c:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  801f1f:	eb 30                	jmp    801f51 <spawn+0x193>
		argv_store[i] = UTEMP2USTACK(string_store);
  801f21:	8d 87 00 d0 7f ee    	lea    -0x11803000(%edi),%eax
  801f27:	8b 8d 90 fd ff ff    	mov    -0x270(%ebp),%ecx
  801f2d:	89 04 b1             	mov    %eax,(%ecx,%esi,4)
		strcpy(string_store, argv[i]);
  801f30:	83 ec 08             	sub    $0x8,%esp
  801f33:	ff 34 b3             	pushl  (%ebx,%esi,4)
  801f36:	57                   	push   %edi
  801f37:	e8 a4 ec ff ff       	call   800be0 <strcpy>
		string_store += strlen(argv[i]) + 1;
  801f3c:	83 c4 04             	add    $0x4,%esp
  801f3f:	ff 34 b3             	pushl  (%ebx,%esi,4)
  801f42:	e8 56 ec ff ff       	call   800b9d <strlen>
  801f47:	8d 7c 07 01          	lea    0x1(%edi,%eax,1),%edi
	for (i = 0; i < argc; i++) {
  801f4b:	83 c6 01             	add    $0x1,%esi
  801f4e:	83 c4 10             	add    $0x10,%esp
  801f51:	39 b5 8c fd ff ff    	cmp    %esi,-0x274(%ebp)
  801f57:	7f c8                	jg     801f21 <spawn+0x163>
	}
	argv_store[argc] = 0;
  801f59:	8b 85 90 fd ff ff    	mov    -0x270(%ebp),%eax
  801f5f:	8b 8d 80 fd ff ff    	mov    -0x280(%ebp),%ecx
  801f65:	c7 04 08 00 00 00 00 	movl   $0x0,(%eax,%ecx,1)
	assert(string_store == (char*)UTEMP + PGSIZE);
  801f6c:	81 ff 00 10 40 00    	cmp    $0x401000,%edi
  801f72:	0f 85 86 00 00 00    	jne    801ffe <spawn+0x240>

	argv_store[-1] = UTEMP2USTACK(argv_store);
  801f78:	8b 95 90 fd ff ff    	mov    -0x270(%ebp),%edx
  801f7e:	8d 82 00 d0 7f ee    	lea    -0x11803000(%edx),%eax
  801f84:	89 42 fc             	mov    %eax,-0x4(%edx)
	argv_store[-2] = argc;
  801f87:	89 d0                	mov    %edx,%eax
  801f89:	8b 8d 84 fd ff ff    	mov    -0x27c(%ebp),%ecx
  801f8f:	89 4a f8             	mov    %ecx,-0x8(%edx)

	*init_esp = UTEMP2USTACK(&argv_store[-2]);
  801f92:	2d 08 30 80 11       	sub    $0x11803008,%eax
  801f97:	89 85 e0 fd ff ff    	mov    %eax,-0x220(%ebp)

	// After completing the stack, map it into the child's address space
	// and unmap it from ours!
	if ((r = sys_page_map(0, UTEMP, child, (void*) (USTACKTOP - PGSIZE), PTE_P | PTE_U | PTE_W)) < 0)
  801f9d:	83 ec 0c             	sub    $0xc,%esp
  801fa0:	6a 07                	push   $0x7
  801fa2:	68 00 d0 bf ee       	push   $0xeebfd000
  801fa7:	ff b5 74 fd ff ff    	pushl  -0x28c(%ebp)
  801fad:	68 00 00 40 00       	push   $0x400000
  801fb2:	6a 00                	push   $0x0
  801fb4:	e8 b0 f0 ff ff       	call   801069 <sys_page_map>
  801fb9:	89 c3                	mov    %eax,%ebx
  801fbb:	83 c4 20             	add    $0x20,%esp
  801fbe:	85 c0                	test   %eax,%eax
  801fc0:	0f 88 38 03 00 00    	js     8022fe <spawn+0x540>
		goto error;
	if ((r = sys_page_unmap(0, UTEMP)) < 0)
  801fc6:	83 ec 08             	sub    $0x8,%esp
  801fc9:	68 00 00 40 00       	push   $0x400000
  801fce:	6a 00                	push   $0x0
  801fd0:	e8 da f0 ff ff       	call   8010af <sys_page_unmap>
  801fd5:	89 c3                	mov    %eax,%ebx
  801fd7:	83 c4 10             	add    $0x10,%esp
  801fda:	85 c0                	test   %eax,%eax
  801fdc:	0f 88 1c 03 00 00    	js     8022fe <spawn+0x540>
	ph = (struct Proghdr*) (elf_buf + elf->e_phoff);
  801fe2:	8b 85 04 fe ff ff    	mov    -0x1fc(%ebp),%eax
  801fe8:	8d b4 05 e8 fd ff ff 	lea    -0x218(%ebp,%eax,1),%esi
	for (i = 0; i < elf->e_phnum; i++, ph++) {
  801fef:	c7 85 84 fd ff ff 00 	movl   $0x0,-0x27c(%ebp)
  801ff6:	00 00 00 
  801ff9:	e9 4f 01 00 00       	jmp    80214d <spawn+0x38f>
	assert(string_store == (char*)UTEMP + PGSIZE);
  801ffe:	68 10 33 80 00       	push   $0x803310
  802003:	68 6f 32 80 00       	push   $0x80326f
  802008:	68 f2 00 00 00       	push   $0xf2
  80200d:	68 b5 32 80 00       	push   $0x8032b5
  802012:	e8 09 e5 ff ff       	call   800520 <_panic>
			// allocate a blank page
			if ((r = sys_page_alloc(child, (void*) (va + i), perm)) < 0)
				return r;
		} else {
			// from file
			if ((r = sys_page_alloc(0, UTEMP, PTE_P|PTE_U|PTE_W)) < 0)
  802017:	83 ec 04             	sub    $0x4,%esp
  80201a:	6a 07                	push   $0x7
  80201c:	68 00 00 40 00       	push   $0x400000
  802021:	6a 00                	push   $0x0
  802023:	e8 fa ef ff ff       	call   801022 <sys_page_alloc>
  802028:	83 c4 10             	add    $0x10,%esp
  80202b:	85 c0                	test   %eax,%eax
  80202d:	0f 88 a9 02 00 00    	js     8022dc <spawn+0x51e>
				return r;
			if ((r = seek(fd, fileoffset + i)) < 0)
  802033:	83 ec 08             	sub    $0x8,%esp
  802036:	8b 85 80 fd ff ff    	mov    -0x280(%ebp),%eax
  80203c:	01 f0                	add    %esi,%eax
  80203e:	50                   	push   %eax
  80203f:	ff b5 94 fd ff ff    	pushl  -0x26c(%ebp)
  802045:	e8 8e f9 ff ff       	call   8019d8 <seek>
  80204a:	83 c4 10             	add    $0x10,%esp
  80204d:	85 c0                	test   %eax,%eax
  80204f:	0f 88 8e 02 00 00    	js     8022e3 <spawn+0x525>
				return r;
			if ((r = readn(fd, UTEMP, MIN(PGSIZE, filesz-i))) < 0)
  802055:	83 ec 04             	sub    $0x4,%esp
  802058:	8b 85 90 fd ff ff    	mov    -0x270(%ebp),%eax
  80205e:	29 f0                	sub    %esi,%eax
  802060:	3d 00 10 00 00       	cmp    $0x1000,%eax
  802065:	b9 00 10 00 00       	mov    $0x1000,%ecx
  80206a:	0f 47 c1             	cmova  %ecx,%eax
  80206d:	50                   	push   %eax
  80206e:	68 00 00 40 00       	push   $0x400000
  802073:	ff b5 94 fd ff ff    	pushl  -0x26c(%ebp)
  802079:	e8 89 f8 ff ff       	call   801907 <readn>
  80207e:	83 c4 10             	add    $0x10,%esp
  802081:	85 c0                	test   %eax,%eax
  802083:	0f 88 61 02 00 00    	js     8022ea <spawn+0x52c>
				return r;
			if ((r = sys_page_map(0, UTEMP, child, (void*) (va + i), perm)) < 0)
  802089:	83 ec 0c             	sub    $0xc,%esp
  80208c:	ff b5 8c fd ff ff    	pushl  -0x274(%ebp)
  802092:	53                   	push   %ebx
  802093:	ff b5 88 fd ff ff    	pushl  -0x278(%ebp)
  802099:	68 00 00 40 00       	push   $0x400000
  80209e:	6a 00                	push   $0x0
  8020a0:	e8 c4 ef ff ff       	call   801069 <sys_page_map>
  8020a5:	83 c4 20             	add    $0x20,%esp
  8020a8:	85 c0                	test   %eax,%eax
  8020aa:	78 7c                	js     802128 <spawn+0x36a>
				panic("spawn: sys_page_map data: %e", r);
			sys_page_unmap(0, UTEMP);
  8020ac:	83 ec 08             	sub    $0x8,%esp
  8020af:	68 00 00 40 00       	push   $0x400000
  8020b4:	6a 00                	push   $0x0
  8020b6:	e8 f4 ef ff ff       	call   8010af <sys_page_unmap>
  8020bb:	83 c4 10             	add    $0x10,%esp
	for (i = 0; i < memsz; i += PGSIZE) {
  8020be:	81 c7 00 10 00 00    	add    $0x1000,%edi
  8020c4:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  8020ca:	89 fe                	mov    %edi,%esi
  8020cc:	39 bd 7c fd ff ff    	cmp    %edi,-0x284(%ebp)
  8020d2:	76 69                	jbe    80213d <spawn+0x37f>
		if (i >= filesz) {
  8020d4:	39 bd 90 fd ff ff    	cmp    %edi,-0x270(%ebp)
  8020da:	0f 87 37 ff ff ff    	ja     802017 <spawn+0x259>
			if ((r = sys_page_alloc(child, (void*) (va + i), perm)) < 0)
  8020e0:	83 ec 04             	sub    $0x4,%esp
  8020e3:	ff b5 8c fd ff ff    	pushl  -0x274(%ebp)
  8020e9:	53                   	push   %ebx
  8020ea:	ff b5 88 fd ff ff    	pushl  -0x278(%ebp)
  8020f0:	e8 2d ef ff ff       	call   801022 <sys_page_alloc>
  8020f5:	83 c4 10             	add    $0x10,%esp
  8020f8:	85 c0                	test   %eax,%eax
  8020fa:	79 c2                	jns    8020be <spawn+0x300>
  8020fc:	89 c7                	mov    %eax,%edi
	sys_env_destroy(child);
  8020fe:	83 ec 0c             	sub    $0xc,%esp
  802101:	ff b5 74 fd ff ff    	pushl  -0x28c(%ebp)
  802107:	e8 8b ee ff ff       	call   800f97 <sys_env_destroy>
	close(fd);
  80210c:	83 c4 04             	add    $0x4,%esp
  80210f:	ff b5 94 fd ff ff    	pushl  -0x26c(%ebp)
  802115:	e8 18 f6 ff ff       	call   801732 <close>
	return r;
  80211a:	83 c4 10             	add    $0x10,%esp
  80211d:	89 bd 94 fd ff ff    	mov    %edi,-0x26c(%ebp)
  802123:	e9 a6 01 00 00       	jmp    8022ce <spawn+0x510>
				panic("spawn: sys_page_map data: %e", r);
  802128:	50                   	push   %eax
  802129:	68 c1 32 80 00       	push   $0x8032c1
  80212e:	68 25 01 00 00       	push   $0x125
  802133:	68 b5 32 80 00       	push   $0x8032b5
  802138:	e8 e3 e3 ff ff       	call   800520 <_panic>
  80213d:	8b b5 78 fd ff ff    	mov    -0x288(%ebp),%esi
	for (i = 0; i < elf->e_phnum; i++, ph++) {
  802143:	83 85 84 fd ff ff 01 	addl   $0x1,-0x27c(%ebp)
  80214a:	83 c6 20             	add    $0x20,%esi
  80214d:	0f b7 85 14 fe ff ff 	movzwl -0x1ec(%ebp),%eax
  802154:	3b 85 84 fd ff ff    	cmp    -0x27c(%ebp),%eax
  80215a:	7e 6d                	jle    8021c9 <spawn+0x40b>
		if (ph->p_type != ELF_PROG_LOAD)
  80215c:	83 3e 01             	cmpl   $0x1,(%esi)
  80215f:	75 e2                	jne    802143 <spawn+0x385>
		if (ph->p_flags & ELF_PROG_FLAG_WRITE)
  802161:	8b 46 18             	mov    0x18(%esi),%eax
  802164:	83 e0 02             	and    $0x2,%eax
			perm |= PTE_W;
  802167:	83 f8 01             	cmp    $0x1,%eax
  80216a:	19 c0                	sbb    %eax,%eax
  80216c:	83 e0 fe             	and    $0xfffffffe,%eax
  80216f:	83 c0 07             	add    $0x7,%eax
  802172:	89 85 8c fd ff ff    	mov    %eax,-0x274(%ebp)
		if ((r = map_segment(child, ph->p_va, ph->p_memsz,
  802178:	8b 4e 04             	mov    0x4(%esi),%ecx
  80217b:	89 8d 80 fd ff ff    	mov    %ecx,-0x280(%ebp)
  802181:	8b 56 10             	mov    0x10(%esi),%edx
  802184:	89 95 90 fd ff ff    	mov    %edx,-0x270(%ebp)
  80218a:	8b 7e 14             	mov    0x14(%esi),%edi
  80218d:	89 bd 7c fd ff ff    	mov    %edi,-0x284(%ebp)
  802193:	8b 5e 08             	mov    0x8(%esi),%ebx
	if ((i = PGOFF(va))) {
  802196:	89 d8                	mov    %ebx,%eax
  802198:	25 ff 0f 00 00       	and    $0xfff,%eax
  80219d:	74 1a                	je     8021b9 <spawn+0x3fb>
		va -= i;
  80219f:	29 c3                	sub    %eax,%ebx
		memsz += i;
  8021a1:	01 c7                	add    %eax,%edi
  8021a3:	89 bd 7c fd ff ff    	mov    %edi,-0x284(%ebp)
		filesz += i;
  8021a9:	01 c2                	add    %eax,%edx
  8021ab:	89 95 90 fd ff ff    	mov    %edx,-0x270(%ebp)
		fileoffset -= i;
  8021b1:	29 c1                	sub    %eax,%ecx
  8021b3:	89 8d 80 fd ff ff    	mov    %ecx,-0x280(%ebp)
	for (i = 0; i < memsz; i += PGSIZE) {
  8021b9:	bf 00 00 00 00       	mov    $0x0,%edi
  8021be:	89 b5 78 fd ff ff    	mov    %esi,-0x288(%ebp)
  8021c4:	e9 01 ff ff ff       	jmp    8020ca <spawn+0x30c>
	close(fd);
  8021c9:	83 ec 0c             	sub    $0xc,%esp
  8021cc:	ff b5 94 fd ff ff    	pushl  -0x26c(%ebp)
  8021d2:	e8 5b f5 ff ff       	call   801732 <close>
  8021d7:	83 c4 10             	add    $0x10,%esp
static int
copy_shared_pages(envid_t child)
{
	// LAB 5: Your code here.
	uintptr_t addr;
	for (addr = 0; addr < UTOP; addr += PGSIZE) {
  8021da:	bb 00 00 00 00       	mov    $0x0,%ebx
  8021df:	8b b5 88 fd ff ff    	mov    -0x278(%ebp),%esi
  8021e5:	eb 2b                	jmp    802212 <spawn+0x454>
		if ((uvpd[PDX(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_P) &&
				(uvpt[PGNUM(addr)] & PTE_U) && (uvpt[PGNUM(addr)] & PTE_SHARE)) {
            sys_page_map(0, (void*)addr, child, (void*)addr, (uvpt[PGNUM(addr)] & PTE_SYSCALL));
  8021e7:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  8021ee:	83 ec 0c             	sub    $0xc,%esp
  8021f1:	25 07 0e 00 00       	and    $0xe07,%eax
  8021f6:	50                   	push   %eax
  8021f7:	53                   	push   %ebx
  8021f8:	56                   	push   %esi
  8021f9:	53                   	push   %ebx
  8021fa:	6a 00                	push   $0x0
  8021fc:	e8 68 ee ff ff       	call   801069 <sys_page_map>
  802201:	83 c4 20             	add    $0x20,%esp
	for (addr = 0; addr < UTOP; addr += PGSIZE) {
  802204:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  80220a:	81 fb 00 00 c0 ee    	cmp    $0xeec00000,%ebx
  802210:	74 3b                	je     80224d <spawn+0x48f>
		if ((uvpd[PDX(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_P) &&
  802212:	89 d8                	mov    %ebx,%eax
  802214:	c1 e8 16             	shr    $0x16,%eax
  802217:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  80221e:	a8 01                	test   $0x1,%al
  802220:	74 e2                	je     802204 <spawn+0x446>
  802222:	89 d8                	mov    %ebx,%eax
  802224:	c1 e8 0c             	shr    $0xc,%eax
  802227:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
  80222e:	f6 c2 01             	test   $0x1,%dl
  802231:	74 d1                	je     802204 <spawn+0x446>
				(uvpt[PGNUM(addr)] & PTE_U) && (uvpt[PGNUM(addr)] & PTE_SHARE)) {
  802233:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
		if ((uvpd[PDX(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_P) &&
  80223a:	f6 c2 04             	test   $0x4,%dl
  80223d:	74 c5                	je     802204 <spawn+0x446>
				(uvpt[PGNUM(addr)] & PTE_U) && (uvpt[PGNUM(addr)] & PTE_SHARE)) {
  80223f:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
  802246:	f6 c6 04             	test   $0x4,%dh
  802249:	74 b9                	je     802204 <spawn+0x446>
  80224b:	eb 9a                	jmp    8021e7 <spawn+0x429>
	child_tf.tf_eflags |= FL_IOPL_3;   // devious: see user/faultio.c
  80224d:	81 8d dc fd ff ff 00 	orl    $0x3000,-0x224(%ebp)
  802254:	30 00 00 
	if ((r = sys_env_set_trapframe(child, &child_tf)) < 0)
  802257:	83 ec 08             	sub    $0x8,%esp
  80225a:	8d 85 a4 fd ff ff    	lea    -0x25c(%ebp),%eax
  802260:	50                   	push   %eax
  802261:	ff b5 74 fd ff ff    	pushl  -0x28c(%ebp)
  802267:	e8 cf ee ff ff       	call   80113b <sys_env_set_trapframe>
  80226c:	83 c4 10             	add    $0x10,%esp
  80226f:	85 c0                	test   %eax,%eax
  802271:	78 25                	js     802298 <spawn+0x4da>
	if ((r = sys_env_set_status(child, ENV_RUNNABLE)) < 0)
  802273:	83 ec 08             	sub    $0x8,%esp
  802276:	6a 02                	push   $0x2
  802278:	ff b5 74 fd ff ff    	pushl  -0x28c(%ebp)
  80227e:	e8 72 ee ff ff       	call   8010f5 <sys_env_set_status>
  802283:	83 c4 10             	add    $0x10,%esp
  802286:	85 c0                	test   %eax,%eax
  802288:	78 23                	js     8022ad <spawn+0x4ef>
	return child;
  80228a:	8b 85 74 fd ff ff    	mov    -0x28c(%ebp),%eax
  802290:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
  802296:	eb 36                	jmp    8022ce <spawn+0x510>
		panic("sys_env_set_trapframe: %e", r);
  802298:	50                   	push   %eax
  802299:	68 de 32 80 00       	push   $0x8032de
  80229e:	68 86 00 00 00       	push   $0x86
  8022a3:	68 b5 32 80 00       	push   $0x8032b5
  8022a8:	e8 73 e2 ff ff       	call   800520 <_panic>
		panic("sys_env_set_status: %e", r);
  8022ad:	50                   	push   %eax
  8022ae:	68 f8 32 80 00       	push   $0x8032f8
  8022b3:	68 89 00 00 00       	push   $0x89
  8022b8:	68 b5 32 80 00       	push   $0x8032b5
  8022bd:	e8 5e e2 ff ff       	call   800520 <_panic>
		return r;
  8022c2:	8b 85 74 fd ff ff    	mov    -0x28c(%ebp),%eax
  8022c8:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
}
  8022ce:	8b 85 94 fd ff ff    	mov    -0x26c(%ebp),%eax
  8022d4:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8022d7:	5b                   	pop    %ebx
  8022d8:	5e                   	pop    %esi
  8022d9:	5f                   	pop    %edi
  8022da:	5d                   	pop    %ebp
  8022db:	c3                   	ret    
  8022dc:	89 c7                	mov    %eax,%edi
  8022de:	e9 1b fe ff ff       	jmp    8020fe <spawn+0x340>
  8022e3:	89 c7                	mov    %eax,%edi
  8022e5:	e9 14 fe ff ff       	jmp    8020fe <spawn+0x340>
  8022ea:	89 c7                	mov    %eax,%edi
  8022ec:	e9 0d fe ff ff       	jmp    8020fe <spawn+0x340>
		return -E_NO_MEM;
  8022f1:	b8 fc ff ff ff       	mov    $0xfffffffc,%eax
	for (addr = 0; addr < UTOP; addr += PGSIZE) {
  8022f6:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
  8022fc:	eb d0                	jmp    8022ce <spawn+0x510>
	sys_page_unmap(0, UTEMP);
  8022fe:	83 ec 08             	sub    $0x8,%esp
  802301:	68 00 00 40 00       	push   $0x400000
  802306:	6a 00                	push   $0x0
  802308:	e8 a2 ed ff ff       	call   8010af <sys_page_unmap>
  80230d:	83 c4 10             	add    $0x10,%esp
  802310:	89 9d 94 fd ff ff    	mov    %ebx,-0x26c(%ebp)
  802316:	eb b6                	jmp    8022ce <spawn+0x510>

00802318 <spawnl>:
{
  802318:	f3 0f 1e fb          	endbr32 
  80231c:	55                   	push   %ebp
  80231d:	89 e5                	mov    %esp,%ebp
  80231f:	57                   	push   %edi
  802320:	56                   	push   %esi
  802321:	53                   	push   %ebx
  802322:	83 ec 0c             	sub    $0xc,%esp
	va_start(vl, arg0);
  802325:	8d 55 10             	lea    0x10(%ebp),%edx
	int argc=0;
  802328:	b8 00 00 00 00       	mov    $0x0,%eax
	while(va_arg(vl, void *) != NULL)
  80232d:	8d 4a 04             	lea    0x4(%edx),%ecx
  802330:	83 3a 00             	cmpl   $0x0,(%edx)
  802333:	74 07                	je     80233c <spawnl+0x24>
		argc++;
  802335:	83 c0 01             	add    $0x1,%eax
	while(va_arg(vl, void *) != NULL)
  802338:	89 ca                	mov    %ecx,%edx
  80233a:	eb f1                	jmp    80232d <spawnl+0x15>
	const char *argv[argc+2];
  80233c:	8d 14 85 17 00 00 00 	lea    0x17(,%eax,4),%edx
  802343:	89 d1                	mov    %edx,%ecx
  802345:	83 e1 f0             	and    $0xfffffff0,%ecx
  802348:	81 e2 00 f0 ff ff    	and    $0xfffff000,%edx
  80234e:	89 e6                	mov    %esp,%esi
  802350:	29 d6                	sub    %edx,%esi
  802352:	89 f2                	mov    %esi,%edx
  802354:	39 d4                	cmp    %edx,%esp
  802356:	74 10                	je     802368 <spawnl+0x50>
  802358:	81 ec 00 10 00 00    	sub    $0x1000,%esp
  80235e:	83 8c 24 fc 0f 00 00 	orl    $0x0,0xffc(%esp)
  802365:	00 
  802366:	eb ec                	jmp    802354 <spawnl+0x3c>
  802368:	89 ca                	mov    %ecx,%edx
  80236a:	81 e2 ff 0f 00 00    	and    $0xfff,%edx
  802370:	29 d4                	sub    %edx,%esp
  802372:	85 d2                	test   %edx,%edx
  802374:	74 05                	je     80237b <spawnl+0x63>
  802376:	83 4c 14 fc 00       	orl    $0x0,-0x4(%esp,%edx,1)
  80237b:	8d 74 24 03          	lea    0x3(%esp),%esi
  80237f:	89 f2                	mov    %esi,%edx
  802381:	c1 ea 02             	shr    $0x2,%edx
  802384:	83 e6 fc             	and    $0xfffffffc,%esi
  802387:	89 f3                	mov    %esi,%ebx
	argv[0] = arg0;
  802389:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80238c:	89 0c 95 00 00 00 00 	mov    %ecx,0x0(,%edx,4)
	argv[argc+1] = NULL;
  802393:	c7 44 86 04 00 00 00 	movl   $0x0,0x4(%esi,%eax,4)
  80239a:	00 
	va_start(vl, arg0);
  80239b:	8d 4d 10             	lea    0x10(%ebp),%ecx
  80239e:	89 c2                	mov    %eax,%edx
	for(i=0;i<argc;i++)
  8023a0:	b8 00 00 00 00       	mov    $0x0,%eax
  8023a5:	eb 0b                	jmp    8023b2 <spawnl+0x9a>
		argv[i+1] = va_arg(vl, const char *);
  8023a7:	83 c0 01             	add    $0x1,%eax
  8023aa:	8b 39                	mov    (%ecx),%edi
  8023ac:	89 3c 83             	mov    %edi,(%ebx,%eax,4)
  8023af:	8d 49 04             	lea    0x4(%ecx),%ecx
	for(i=0;i<argc;i++)
  8023b2:	39 d0                	cmp    %edx,%eax
  8023b4:	75 f1                	jne    8023a7 <spawnl+0x8f>
	return spawn(prog, argv);
  8023b6:	83 ec 08             	sub    $0x8,%esp
  8023b9:	56                   	push   %esi
  8023ba:	ff 75 08             	pushl  0x8(%ebp)
  8023bd:	e8 fc f9 ff ff       	call   801dbe <spawn>
}
  8023c2:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8023c5:	5b                   	pop    %ebx
  8023c6:	5e                   	pop    %esi
  8023c7:	5f                   	pop    %edi
  8023c8:	5d                   	pop    %ebp
  8023c9:	c3                   	ret    

008023ca <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  8023ca:	f3 0f 1e fb          	endbr32 
  8023ce:	55                   	push   %ebp
  8023cf:	89 e5                	mov    %esp,%ebp
  8023d1:	56                   	push   %esi
  8023d2:	53                   	push   %ebx
  8023d3:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  8023d6:	83 ec 0c             	sub    $0xc,%esp
  8023d9:	ff 75 08             	pushl  0x8(%ebp)
  8023dc:	e8 a7 f1 ff ff       	call   801588 <fd2data>
  8023e1:	89 c6                	mov    %eax,%esi
	strcpy(stat->st_name, "<pipe>");
  8023e3:	83 c4 08             	add    $0x8,%esp
  8023e6:	68 36 33 80 00       	push   $0x803336
  8023eb:	53                   	push   %ebx
  8023ec:	e8 ef e7 ff ff       	call   800be0 <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  8023f1:	8b 46 04             	mov    0x4(%esi),%eax
  8023f4:	2b 06                	sub    (%esi),%eax
  8023f6:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	stat->st_isdir = 0;
  8023fc:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  802403:	00 00 00 
	stat->st_dev = &devpipe;
  802406:	c7 83 88 00 00 00 3c 	movl   $0x80403c,0x88(%ebx)
  80240d:	40 80 00 
	return 0;
}
  802410:	b8 00 00 00 00       	mov    $0x0,%eax
  802415:	8d 65 f8             	lea    -0x8(%ebp),%esp
  802418:	5b                   	pop    %ebx
  802419:	5e                   	pop    %esi
  80241a:	5d                   	pop    %ebp
  80241b:	c3                   	ret    

0080241c <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  80241c:	f3 0f 1e fb          	endbr32 
  802420:	55                   	push   %ebp
  802421:	89 e5                	mov    %esp,%ebp
  802423:	53                   	push   %ebx
  802424:	83 ec 0c             	sub    $0xc,%esp
  802427:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  80242a:	53                   	push   %ebx
  80242b:	6a 00                	push   $0x0
  80242d:	e8 7d ec ff ff       	call   8010af <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  802432:	89 1c 24             	mov    %ebx,(%esp)
  802435:	e8 4e f1 ff ff       	call   801588 <fd2data>
  80243a:	83 c4 08             	add    $0x8,%esp
  80243d:	50                   	push   %eax
  80243e:	6a 00                	push   $0x0
  802440:	e8 6a ec ff ff       	call   8010af <sys_page_unmap>
}
  802445:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  802448:	c9                   	leave  
  802449:	c3                   	ret    

0080244a <_pipeisclosed>:
{
  80244a:	55                   	push   %ebp
  80244b:	89 e5                	mov    %esp,%ebp
  80244d:	57                   	push   %edi
  80244e:	56                   	push   %esi
  80244f:	53                   	push   %ebx
  802450:	83 ec 1c             	sub    $0x1c,%esp
  802453:	89 c7                	mov    %eax,%edi
  802455:	89 d6                	mov    %edx,%esi
		n = thisenv->env_runs;
  802457:	a1 04 50 80 00       	mov    0x805004,%eax
  80245c:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  80245f:	83 ec 0c             	sub    $0xc,%esp
  802462:	57                   	push   %edi
  802463:	e8 d2 04 00 00       	call   80293a <pageref>
  802468:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  80246b:	89 34 24             	mov    %esi,(%esp)
  80246e:	e8 c7 04 00 00       	call   80293a <pageref>
		nn = thisenv->env_runs;
  802473:	8b 15 04 50 80 00    	mov    0x805004,%edx
  802479:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  80247c:	83 c4 10             	add    $0x10,%esp
  80247f:	39 cb                	cmp    %ecx,%ebx
  802481:	74 1b                	je     80249e <_pipeisclosed+0x54>
		if (n != nn && ret == 1)
  802483:	39 45 e4             	cmp    %eax,-0x1c(%ebp)
  802486:	75 cf                	jne    802457 <_pipeisclosed+0xd>
			cprintf("pipe race avoided\n", n, thisenv->env_runs, ret);
  802488:	8b 42 58             	mov    0x58(%edx),%eax
  80248b:	6a 01                	push   $0x1
  80248d:	50                   	push   %eax
  80248e:	53                   	push   %ebx
  80248f:	68 3d 33 80 00       	push   $0x80333d
  802494:	e8 6e e1 ff ff       	call   800607 <cprintf>
  802499:	83 c4 10             	add    $0x10,%esp
  80249c:	eb b9                	jmp    802457 <_pipeisclosed+0xd>
		ret = pageref(fd) == pageref(p);
  80249e:	39 45 e4             	cmp    %eax,-0x1c(%ebp)
  8024a1:	0f 94 c0             	sete   %al
  8024a4:	0f b6 c0             	movzbl %al,%eax
}
  8024a7:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8024aa:	5b                   	pop    %ebx
  8024ab:	5e                   	pop    %esi
  8024ac:	5f                   	pop    %edi
  8024ad:	5d                   	pop    %ebp
  8024ae:	c3                   	ret    

008024af <devpipe_write>:
{
  8024af:	f3 0f 1e fb          	endbr32 
  8024b3:	55                   	push   %ebp
  8024b4:	89 e5                	mov    %esp,%ebp
  8024b6:	57                   	push   %edi
  8024b7:	56                   	push   %esi
  8024b8:	53                   	push   %ebx
  8024b9:	83 ec 28             	sub    $0x28,%esp
  8024bc:	8b 75 08             	mov    0x8(%ebp),%esi
	p = (struct Pipe*) fd2data(fd);
  8024bf:	56                   	push   %esi
  8024c0:	e8 c3 f0 ff ff       	call   801588 <fd2data>
  8024c5:	89 c3                	mov    %eax,%ebx
	for (i = 0; i < n; i++) {
  8024c7:	83 c4 10             	add    $0x10,%esp
  8024ca:	bf 00 00 00 00       	mov    $0x0,%edi
  8024cf:	3b 7d 10             	cmp    0x10(%ebp),%edi
  8024d2:	74 4f                	je     802523 <devpipe_write+0x74>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  8024d4:	8b 43 04             	mov    0x4(%ebx),%eax
  8024d7:	8b 0b                	mov    (%ebx),%ecx
  8024d9:	8d 51 20             	lea    0x20(%ecx),%edx
  8024dc:	39 d0                	cmp    %edx,%eax
  8024de:	72 14                	jb     8024f4 <devpipe_write+0x45>
			if (_pipeisclosed(fd, p))
  8024e0:	89 da                	mov    %ebx,%edx
  8024e2:	89 f0                	mov    %esi,%eax
  8024e4:	e8 61 ff ff ff       	call   80244a <_pipeisclosed>
  8024e9:	85 c0                	test   %eax,%eax
  8024eb:	75 3b                	jne    802528 <devpipe_write+0x79>
			sys_yield();
  8024ed:	e8 0d eb ff ff       	call   800fff <sys_yield>
  8024f2:	eb e0                	jmp    8024d4 <devpipe_write+0x25>
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  8024f4:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8024f7:	0f b6 0c 39          	movzbl (%ecx,%edi,1),%ecx
  8024fb:	88 4d e7             	mov    %cl,-0x19(%ebp)
  8024fe:	89 c2                	mov    %eax,%edx
  802500:	c1 fa 1f             	sar    $0x1f,%edx
  802503:	89 d1                	mov    %edx,%ecx
  802505:	c1 e9 1b             	shr    $0x1b,%ecx
  802508:	8d 14 08             	lea    (%eax,%ecx,1),%edx
  80250b:	83 e2 1f             	and    $0x1f,%edx
  80250e:	29 ca                	sub    %ecx,%edx
  802510:	0f b6 4d e7          	movzbl -0x19(%ebp),%ecx
  802514:	88 4c 13 08          	mov    %cl,0x8(%ebx,%edx,1)
		p->p_wpos++;
  802518:	83 c0 01             	add    $0x1,%eax
  80251b:	89 43 04             	mov    %eax,0x4(%ebx)
	for (i = 0; i < n; i++) {
  80251e:	83 c7 01             	add    $0x1,%edi
  802521:	eb ac                	jmp    8024cf <devpipe_write+0x20>
	return i;
  802523:	8b 45 10             	mov    0x10(%ebp),%eax
  802526:	eb 05                	jmp    80252d <devpipe_write+0x7e>
				return 0;
  802528:	b8 00 00 00 00       	mov    $0x0,%eax
}
  80252d:	8d 65 f4             	lea    -0xc(%ebp),%esp
  802530:	5b                   	pop    %ebx
  802531:	5e                   	pop    %esi
  802532:	5f                   	pop    %edi
  802533:	5d                   	pop    %ebp
  802534:	c3                   	ret    

00802535 <devpipe_read>:
{
  802535:	f3 0f 1e fb          	endbr32 
  802539:	55                   	push   %ebp
  80253a:	89 e5                	mov    %esp,%ebp
  80253c:	57                   	push   %edi
  80253d:	56                   	push   %esi
  80253e:	53                   	push   %ebx
  80253f:	83 ec 18             	sub    $0x18,%esp
  802542:	8b 7d 08             	mov    0x8(%ebp),%edi
	p = (struct Pipe*)fd2data(fd);
  802545:	57                   	push   %edi
  802546:	e8 3d f0 ff ff       	call   801588 <fd2data>
  80254b:	89 c3                	mov    %eax,%ebx
	for (i = 0; i < n; i++) {
  80254d:	83 c4 10             	add    $0x10,%esp
  802550:	be 00 00 00 00       	mov    $0x0,%esi
  802555:	3b 75 10             	cmp    0x10(%ebp),%esi
  802558:	75 14                	jne    80256e <devpipe_read+0x39>
	return i;
  80255a:	8b 45 10             	mov    0x10(%ebp),%eax
  80255d:	eb 02                	jmp    802561 <devpipe_read+0x2c>
				return i;
  80255f:	89 f0                	mov    %esi,%eax
}
  802561:	8d 65 f4             	lea    -0xc(%ebp),%esp
  802564:	5b                   	pop    %ebx
  802565:	5e                   	pop    %esi
  802566:	5f                   	pop    %edi
  802567:	5d                   	pop    %ebp
  802568:	c3                   	ret    
			sys_yield();
  802569:	e8 91 ea ff ff       	call   800fff <sys_yield>
		while (p->p_rpos == p->p_wpos) {
  80256e:	8b 03                	mov    (%ebx),%eax
  802570:	3b 43 04             	cmp    0x4(%ebx),%eax
  802573:	75 18                	jne    80258d <devpipe_read+0x58>
			if (i > 0)
  802575:	85 f6                	test   %esi,%esi
  802577:	75 e6                	jne    80255f <devpipe_read+0x2a>
			if (_pipeisclosed(fd, p))
  802579:	89 da                	mov    %ebx,%edx
  80257b:	89 f8                	mov    %edi,%eax
  80257d:	e8 c8 fe ff ff       	call   80244a <_pipeisclosed>
  802582:	85 c0                	test   %eax,%eax
  802584:	74 e3                	je     802569 <devpipe_read+0x34>
				return 0;
  802586:	b8 00 00 00 00       	mov    $0x0,%eax
  80258b:	eb d4                	jmp    802561 <devpipe_read+0x2c>
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  80258d:	99                   	cltd   
  80258e:	c1 ea 1b             	shr    $0x1b,%edx
  802591:	01 d0                	add    %edx,%eax
  802593:	83 e0 1f             	and    $0x1f,%eax
  802596:	29 d0                	sub    %edx,%eax
  802598:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  80259d:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8025a0:	88 04 31             	mov    %al,(%ecx,%esi,1)
		p->p_rpos++;
  8025a3:	83 03 01             	addl   $0x1,(%ebx)
	for (i = 0; i < n; i++) {
  8025a6:	83 c6 01             	add    $0x1,%esi
  8025a9:	eb aa                	jmp    802555 <devpipe_read+0x20>

008025ab <pipe>:
{
  8025ab:	f3 0f 1e fb          	endbr32 
  8025af:	55                   	push   %ebp
  8025b0:	89 e5                	mov    %esp,%ebp
  8025b2:	56                   	push   %esi
  8025b3:	53                   	push   %ebx
  8025b4:	83 ec 1c             	sub    $0x1c,%esp
	if ((r = fd_alloc(&fd0)) < 0
  8025b7:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8025ba:	50                   	push   %eax
  8025bb:	e8 e3 ef ff ff       	call   8015a3 <fd_alloc>
  8025c0:	89 c3                	mov    %eax,%ebx
  8025c2:	83 c4 10             	add    $0x10,%esp
  8025c5:	85 c0                	test   %eax,%eax
  8025c7:	0f 88 23 01 00 00    	js     8026f0 <pipe+0x145>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  8025cd:	83 ec 04             	sub    $0x4,%esp
  8025d0:	68 07 04 00 00       	push   $0x407
  8025d5:	ff 75 f4             	pushl  -0xc(%ebp)
  8025d8:	6a 00                	push   $0x0
  8025da:	e8 43 ea ff ff       	call   801022 <sys_page_alloc>
  8025df:	89 c3                	mov    %eax,%ebx
  8025e1:	83 c4 10             	add    $0x10,%esp
  8025e4:	85 c0                	test   %eax,%eax
  8025e6:	0f 88 04 01 00 00    	js     8026f0 <pipe+0x145>
	if ((r = fd_alloc(&fd1)) < 0
  8025ec:	83 ec 0c             	sub    $0xc,%esp
  8025ef:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8025f2:	50                   	push   %eax
  8025f3:	e8 ab ef ff ff       	call   8015a3 <fd_alloc>
  8025f8:	89 c3                	mov    %eax,%ebx
  8025fa:	83 c4 10             	add    $0x10,%esp
  8025fd:	85 c0                	test   %eax,%eax
  8025ff:	0f 88 db 00 00 00    	js     8026e0 <pipe+0x135>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802605:	83 ec 04             	sub    $0x4,%esp
  802608:	68 07 04 00 00       	push   $0x407
  80260d:	ff 75 f0             	pushl  -0x10(%ebp)
  802610:	6a 00                	push   $0x0
  802612:	e8 0b ea ff ff       	call   801022 <sys_page_alloc>
  802617:	89 c3                	mov    %eax,%ebx
  802619:	83 c4 10             	add    $0x10,%esp
  80261c:	85 c0                	test   %eax,%eax
  80261e:	0f 88 bc 00 00 00    	js     8026e0 <pipe+0x135>
	va = fd2data(fd0);
  802624:	83 ec 0c             	sub    $0xc,%esp
  802627:	ff 75 f4             	pushl  -0xc(%ebp)
  80262a:	e8 59 ef ff ff       	call   801588 <fd2data>
  80262f:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802631:	83 c4 0c             	add    $0xc,%esp
  802634:	68 07 04 00 00       	push   $0x407
  802639:	50                   	push   %eax
  80263a:	6a 00                	push   $0x0
  80263c:	e8 e1 e9 ff ff       	call   801022 <sys_page_alloc>
  802641:	89 c3                	mov    %eax,%ebx
  802643:	83 c4 10             	add    $0x10,%esp
  802646:	85 c0                	test   %eax,%eax
  802648:	0f 88 82 00 00 00    	js     8026d0 <pipe+0x125>
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80264e:	83 ec 0c             	sub    $0xc,%esp
  802651:	ff 75 f0             	pushl  -0x10(%ebp)
  802654:	e8 2f ef ff ff       	call   801588 <fd2data>
  802659:	c7 04 24 07 04 00 00 	movl   $0x407,(%esp)
  802660:	50                   	push   %eax
  802661:	6a 00                	push   $0x0
  802663:	56                   	push   %esi
  802664:	6a 00                	push   $0x0
  802666:	e8 fe e9 ff ff       	call   801069 <sys_page_map>
  80266b:	89 c3                	mov    %eax,%ebx
  80266d:	83 c4 20             	add    $0x20,%esp
  802670:	85 c0                	test   %eax,%eax
  802672:	78 4e                	js     8026c2 <pipe+0x117>
	fd0->fd_dev_id = devpipe.dev_id;
  802674:	a1 3c 40 80 00       	mov    0x80403c,%eax
  802679:	8b 55 f4             	mov    -0xc(%ebp),%edx
  80267c:	89 02                	mov    %eax,(%edx)
	fd0->fd_omode = O_RDONLY;
  80267e:	8b 55 f4             	mov    -0xc(%ebp),%edx
  802681:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)
	fd1->fd_dev_id = devpipe.dev_id;
  802688:	8b 55 f0             	mov    -0x10(%ebp),%edx
  80268b:	89 02                	mov    %eax,(%edx)
	fd1->fd_omode = O_WRONLY;
  80268d:	8b 45 f0             	mov    -0x10(%ebp),%eax
  802690:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)
	pfd[0] = fd2num(fd0);
  802697:	83 ec 0c             	sub    $0xc,%esp
  80269a:	ff 75 f4             	pushl  -0xc(%ebp)
  80269d:	e8 d2 ee ff ff       	call   801574 <fd2num>
  8026a2:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8026a5:	89 01                	mov    %eax,(%ecx)
	pfd[1] = fd2num(fd1);
  8026a7:	83 c4 04             	add    $0x4,%esp
  8026aa:	ff 75 f0             	pushl  -0x10(%ebp)
  8026ad:	e8 c2 ee ff ff       	call   801574 <fd2num>
  8026b2:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8026b5:	89 41 04             	mov    %eax,0x4(%ecx)
	return 0;
  8026b8:	83 c4 10             	add    $0x10,%esp
  8026bb:	bb 00 00 00 00       	mov    $0x0,%ebx
  8026c0:	eb 2e                	jmp    8026f0 <pipe+0x145>
	sys_page_unmap(0, va);
  8026c2:	83 ec 08             	sub    $0x8,%esp
  8026c5:	56                   	push   %esi
  8026c6:	6a 00                	push   $0x0
  8026c8:	e8 e2 e9 ff ff       	call   8010af <sys_page_unmap>
  8026cd:	83 c4 10             	add    $0x10,%esp
	sys_page_unmap(0, fd1);
  8026d0:	83 ec 08             	sub    $0x8,%esp
  8026d3:	ff 75 f0             	pushl  -0x10(%ebp)
  8026d6:	6a 00                	push   $0x0
  8026d8:	e8 d2 e9 ff ff       	call   8010af <sys_page_unmap>
  8026dd:	83 c4 10             	add    $0x10,%esp
	sys_page_unmap(0, fd0);
  8026e0:	83 ec 08             	sub    $0x8,%esp
  8026e3:	ff 75 f4             	pushl  -0xc(%ebp)
  8026e6:	6a 00                	push   $0x0
  8026e8:	e8 c2 e9 ff ff       	call   8010af <sys_page_unmap>
  8026ed:	83 c4 10             	add    $0x10,%esp
}
  8026f0:	89 d8                	mov    %ebx,%eax
  8026f2:	8d 65 f8             	lea    -0x8(%ebp),%esp
  8026f5:	5b                   	pop    %ebx
  8026f6:	5e                   	pop    %esi
  8026f7:	5d                   	pop    %ebp
  8026f8:	c3                   	ret    

008026f9 <pipeisclosed>:
{
  8026f9:	f3 0f 1e fb          	endbr32 
  8026fd:	55                   	push   %ebp
  8026fe:	89 e5                	mov    %esp,%ebp
  802700:	83 ec 20             	sub    $0x20,%esp
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  802703:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802706:	50                   	push   %eax
  802707:	ff 75 08             	pushl  0x8(%ebp)
  80270a:	e8 ea ee ff ff       	call   8015f9 <fd_lookup>
  80270f:	83 c4 10             	add    $0x10,%esp
  802712:	85 c0                	test   %eax,%eax
  802714:	78 18                	js     80272e <pipeisclosed+0x35>
	p = (struct Pipe*) fd2data(fd);
  802716:	83 ec 0c             	sub    $0xc,%esp
  802719:	ff 75 f4             	pushl  -0xc(%ebp)
  80271c:	e8 67 ee ff ff       	call   801588 <fd2data>
  802721:	89 c2                	mov    %eax,%edx
	return _pipeisclosed(fd, p);
  802723:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802726:	e8 1f fd ff ff       	call   80244a <_pipeisclosed>
  80272b:	83 c4 10             	add    $0x10,%esp
}
  80272e:	c9                   	leave  
  80272f:	c3                   	ret    

00802730 <wait>:
#include <inc/lib.h>

// Waits until 'envid' exits.
void
wait(envid_t envid)
{
  802730:	f3 0f 1e fb          	endbr32 
  802734:	55                   	push   %ebp
  802735:	89 e5                	mov    %esp,%ebp
  802737:	56                   	push   %esi
  802738:	53                   	push   %ebx
  802739:	8b 75 08             	mov    0x8(%ebp),%esi
	const volatile struct Env *e;

	assert(envid != 0);
  80273c:	85 f6                	test   %esi,%esi
  80273e:	74 13                	je     802753 <wait+0x23>
	e = &envs[ENVX(envid)];
  802740:	89 f3                	mov    %esi,%ebx
  802742:	81 e3 ff 03 00 00    	and    $0x3ff,%ebx
	while (e->env_id == envid && e->env_status != ENV_FREE)
  802748:	6b db 7c             	imul   $0x7c,%ebx,%ebx
  80274b:	81 c3 00 00 c0 ee    	add    $0xeec00000,%ebx
  802751:	eb 1b                	jmp    80276e <wait+0x3e>
	assert(envid != 0);
  802753:	68 55 33 80 00       	push   $0x803355
  802758:	68 6f 32 80 00       	push   $0x80326f
  80275d:	6a 09                	push   $0x9
  80275f:	68 60 33 80 00       	push   $0x803360
  802764:	e8 b7 dd ff ff       	call   800520 <_panic>
		sys_yield();
  802769:	e8 91 e8 ff ff       	call   800fff <sys_yield>
	while (e->env_id == envid && e->env_status != ENV_FREE)
  80276e:	8b 43 48             	mov    0x48(%ebx),%eax
  802771:	39 f0                	cmp    %esi,%eax
  802773:	75 07                	jne    80277c <wait+0x4c>
  802775:	8b 43 54             	mov    0x54(%ebx),%eax
  802778:	85 c0                	test   %eax,%eax
  80277a:	75 ed                	jne    802769 <wait+0x39>
}
  80277c:	8d 65 f8             	lea    -0x8(%ebp),%esp
  80277f:	5b                   	pop    %ebx
  802780:	5e                   	pop    %esi
  802781:	5d                   	pop    %ebp
  802782:	c3                   	ret    

00802783 <set_pgfault_handler>:
// at UXSTACKTOP), and tell the kernel to call the assembly-language
// _pgfault_upcall routine when a page fault occurs.
//
void
set_pgfault_handler(void (*handler)(struct UTrapframe *utf))
{
  802783:	f3 0f 1e fb          	endbr32 
  802787:	55                   	push   %ebp
  802788:	89 e5                	mov    %esp,%ebp
  80278a:	83 ec 08             	sub    $0x8,%esp
	int r;

	if (_pgfault_handler == 0) {
  80278d:	83 3d 00 70 80 00 00 	cmpl   $0x0,0x807000
  802794:	74 27                	je     8027bd <set_pgfault_handler+0x3a>
		if(sys_page_alloc(0,(void *)UXSTACKTOP-PGSIZE,PTE_W|PTE_U|PTE_P)<0)
			panic("set_pgfault_handler:sys_page_alloc failed");
	}

	// Save handler pointer for assembly to call.
	_pgfault_handler = handler;
  802796:	8b 45 08             	mov    0x8(%ebp),%eax
  802799:	a3 00 70 80 00       	mov    %eax,0x807000
	if (sys_env_set_pgfault_upcall(thisenv->env_id,_pgfault_upcall)<0)	
  80279e:	a1 04 50 80 00       	mov    0x805004,%eax
  8027a3:	8b 40 48             	mov    0x48(%eax),%eax
  8027a6:	83 ec 08             	sub    $0x8,%esp
  8027a9:	68 fd 27 80 00       	push   $0x8027fd
  8027ae:	50                   	push   %eax
  8027af:	e8 cd e9 ff ff       	call   801181 <sys_env_set_pgfault_upcall>
  8027b4:	83 c4 10             	add    $0x10,%esp
  8027b7:	85 c0                	test   %eax,%eax
  8027b9:	78 2e                	js     8027e9 <set_pgfault_handler+0x66>
        panic("set_pgfault_handler:sys_env_set_pgfault_upcall failed");
}
  8027bb:	c9                   	leave  
  8027bc:	c3                   	ret    
		if(sys_page_alloc(0,(void *)UXSTACKTOP-PGSIZE,PTE_W|PTE_U|PTE_P)<0)
  8027bd:	83 ec 04             	sub    $0x4,%esp
  8027c0:	6a 07                	push   $0x7
  8027c2:	68 00 f0 bf ee       	push   $0xeebff000
  8027c7:	6a 00                	push   $0x0
  8027c9:	e8 54 e8 ff ff       	call   801022 <sys_page_alloc>
  8027ce:	83 c4 10             	add    $0x10,%esp
  8027d1:	85 c0                	test   %eax,%eax
  8027d3:	79 c1                	jns    802796 <set_pgfault_handler+0x13>
			panic("set_pgfault_handler:sys_page_alloc failed");
  8027d5:	83 ec 04             	sub    $0x4,%esp
  8027d8:	68 6c 33 80 00       	push   $0x80336c
  8027dd:	6a 21                	push   $0x21
  8027df:	68 ce 33 80 00       	push   $0x8033ce
  8027e4:	e8 37 dd ff ff       	call   800520 <_panic>
        panic("set_pgfault_handler:sys_env_set_pgfault_upcall failed");
  8027e9:	83 ec 04             	sub    $0x4,%esp
  8027ec:	68 98 33 80 00       	push   $0x803398
  8027f1:	6a 27                	push   $0x27
  8027f3:	68 ce 33 80 00       	push   $0x8033ce
  8027f8:	e8 23 dd ff ff       	call   800520 <_panic>

008027fd <_pgfault_upcall>:

.text
.globl _pgfault_upcall
_pgfault_upcall:
	// Call the C page fault handler.
	pushl %esp			// function argument: pointer to UTF
  8027fd:	54                   	push   %esp
	movl _pgfault_handler, %eax
  8027fe:	a1 00 70 80 00       	mov    0x807000,%eax
	call *%eax
  802803:	ff d0                	call   *%eax
	addl $4, %esp			// pop function argument
  802805:	83 c4 04             	add    $0x4,%esp
	// may find that you have to rearrange your code in non-obvious
	// ways as registers become unavailable as scratch space.
	//
	// LAB 4: Your code here.
	//首先把此时的eip指针下移48个字节因为UTrapFrame的大小是48个字节
	movl 48(%esp), %ebp
  802808:	8b 6c 24 30          	mov    0x30(%esp),%ebp
    subl $4, %ebp		// UTrapFrame.utf_esp - 4 and store back 这里是由于之前预留了4个字节。
  80280c:	83 ed 04             	sub    $0x4,%ebp
    movl %ebp, 48(%esp)	// 返回上一次的esp位置。
  80280f:	89 6c 24 30          	mov    %ebp,0x30(%esp)

	// Restore the trap-time registers.  After you do this, you
	// can no longer modify any general-purpose registers.
	// LAB 4: Your code here.
	movl 40(%esp), %eax 
  802813:	8b 44 24 28          	mov    0x28(%esp),%eax
    movl %eax, (%ebp)
  802817:	89 45 00             	mov    %eax,0x0(%ebp)

	// Restore eflags from the stack.  After you do this, you can
	// no longer use arithmetic operations or anything else that
	// modifies eflags.
	// LAB 4: Your code here.
	addl $0x8, %esp         // Set %esp to the end of struct PushRegs
  80281a:	83 c4 08             	add    $0x8,%esp
	popal                   // Restore the trap-time registers.(struct PushRegs)
  80281d:	61                   	popa   

	// Switch back to the adjusted trap-time stack.
	// LAB 4: Your code here.
	addl $0x4, %esp         // now we are located at trap-time eip,so we have to increment %esp with 4.【跳过eip】
  80281e:	83 c4 04             	add    $0x4,%esp
	popfl                   // Restore eflags register.	【pop eflags】
  802821:	9d                   	popf   
	popl %esp               // Just restore the adjusted trap-time stack pointer.
  802822:	5c                   	pop    %esp
							// 恢复esp

	// Return to re-execute the instruction that faulted.
	// LAB 4: Your code here.
	ret                     // We are now on the trap-time stack,since we have saved trap-time eip above trap-time esp,ret instruction will pop this trap-time eip to register %eip which known as PC at this time.Thus,we can return to re-execute the instruction that faulted.
  802823:	c3                   	ret    

00802824 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  802824:	f3 0f 1e fb          	endbr32 
  802828:	55                   	push   %ebp
  802829:	89 e5                	mov    %esp,%ebp
  80282b:	56                   	push   %esi
  80282c:	53                   	push   %ebx
  80282d:	8b 75 08             	mov    0x8(%ebp),%esi
  802830:	8b 45 0c             	mov    0xc(%ebp),%eax
  802833:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// LAB 4: Your code here.
	int error;
	if(!pg)pg = (void *)UTOP; // 如果设置为UTOP，这个值其实可以比UTOP大，设置为这个值认为pg无效了，不会进行页面传递【共享页面的设置】，而是只进行值value的传递。
  802836:	85 c0                	test   %eax,%eax
  802838:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  80283d:	0f 44 c2             	cmove  %edx,%eax
	if((error = sys_ipc_recv(pg)) < 0){
  802840:	83 ec 0c             	sub    $0xc,%esp
  802843:	50                   	push   %eax
  802844:	e8 a5 e9 ff ff       	call   8011ee <sys_ipc_recv>
  802849:	83 c4 10             	add    $0x10,%esp
  80284c:	85 c0                	test   %eax,%eax
  80284e:	78 3f                	js     80288f <ipc_recv+0x6b>
		if(from_env_store)*from_env_store = 0;
		if(perm_store)*perm_store = 0;
		return error;
	}

	thisenv = &envs[ENVX(sys_getenvid())]; // for lab4's challenge sfork().
  802850:	e8 87 e7 ff ff       	call   800fdc <sys_getenvid>
  802855:	25 ff 03 00 00       	and    $0x3ff,%eax
  80285a:	6b d0 7c             	imul   $0x7c,%eax,%edx
  80285d:	81 c2 00 00 c0 ee    	add    $0xeec00000,%edx
  802863:	89 15 04 50 80 00    	mov    %edx,0x805004

	if(from_env_store)*from_env_store = thisenv->env_ipc_from;
  802869:	85 f6                	test   %esi,%esi
  80286b:	74 05                	je     802872 <ipc_recv+0x4e>
  80286d:	8b 42 74             	mov    0x74(%edx),%eax
  802870:	89 06                	mov    %eax,(%esi)
	if(perm_store)*perm_store = thisenv->env_ipc_perm;
  802872:	85 db                	test   %ebx,%ebx
  802874:	74 0a                	je     802880 <ipc_recv+0x5c>
  802876:	a1 04 50 80 00       	mov    0x805004,%eax
  80287b:	8b 40 78             	mov    0x78(%eax),%eax
  80287e:	89 03                	mov    %eax,(%ebx)
	return thisenv->env_ipc_value;
  802880:	a1 04 50 80 00       	mov    0x805004,%eax
  802885:	8b 40 70             	mov    0x70(%eax),%eax
}
  802888:	8d 65 f8             	lea    -0x8(%ebp),%esp
  80288b:	5b                   	pop    %ebx
  80288c:	5e                   	pop    %esi
  80288d:	5d                   	pop    %ebp
  80288e:	c3                   	ret    
		if(from_env_store)*from_env_store = 0;
  80288f:	85 f6                	test   %esi,%esi
  802891:	74 06                	je     802899 <ipc_recv+0x75>
  802893:	c7 06 00 00 00 00    	movl   $0x0,(%esi)
		if(perm_store)*perm_store = 0;
  802899:	85 db                	test   %ebx,%ebx
  80289b:	74 eb                	je     802888 <ipc_recv+0x64>
  80289d:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  8028a3:	eb e3                	jmp    802888 <ipc_recv+0x64>

008028a5 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_try_send a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  8028a5:	f3 0f 1e fb          	endbr32 
  8028a9:	55                   	push   %ebp
  8028aa:	89 e5                	mov    %esp,%ebp
  8028ac:	57                   	push   %edi
  8028ad:	56                   	push   %esi
  8028ae:	53                   	push   %ebx
  8028af:	83 ec 0c             	sub    $0xc,%esp
  8028b2:	8b 7d 08             	mov    0x8(%ebp),%edi
  8028b5:	8b 75 0c             	mov    0xc(%ebp),%esi
  8028b8:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// LAB 4: Your code here.
	if(!pg)pg = (void *)UTOP; // 不会进行页面共享，只会sending message。
  8028bb:	85 db                	test   %ebx,%ebx
  8028bd:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  8028c2:	0f 44 d8             	cmove  %eax,%ebx
	int error;
	// Keep trying until it succeeds.
	while((error = sys_ipc_try_send(to_env, val, pg, perm)) < 0){
  8028c5:	ff 75 14             	pushl  0x14(%ebp)
  8028c8:	53                   	push   %ebx
  8028c9:	56                   	push   %esi
  8028ca:	57                   	push   %edi
  8028cb:	e8 f7 e8 ff ff       	call   8011c7 <sys_ipc_try_send>
  8028d0:	83 c4 10             	add    $0x10,%esp
  8028d3:	85 c0                	test   %eax,%eax
  8028d5:	79 1e                	jns    8028f5 <ipc_send+0x50>
        //如果error是没有接收者，那么就会继续尝试send
		if(error != -E_IPC_NOT_RECV){
  8028d7:	83 f8 f9             	cmp    $0xfffffff9,%eax
  8028da:	75 07                	jne    8028e3 <ipc_send+0x3e>
			panic("sys_ipc_try_send:%e", error);
		}
        //但是不是一味的占用cpu，而是尝试一次就释放CPU，等待再次被调度，才会重新send，寻找receiver。
		sys_yield(); // To be CPU-friendly.
  8028dc:	e8 1e e7 ff ff       	call   800fff <sys_yield>
  8028e1:	eb e2                	jmp    8028c5 <ipc_send+0x20>
			panic("sys_ipc_try_send:%e", error);
  8028e3:	50                   	push   %eax
  8028e4:	68 dc 33 80 00       	push   $0x8033dc
  8028e9:	6a 3b                	push   $0x3b
  8028eb:	68 f0 33 80 00       	push   $0x8033f0
  8028f0:	e8 2b dc ff ff       	call   800520 <_panic>
	}
}
  8028f5:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8028f8:	5b                   	pop    %ebx
  8028f9:	5e                   	pop    %esi
  8028fa:	5f                   	pop    %edi
  8028fb:	5d                   	pop    %ebp
  8028fc:	c3                   	ret    

008028fd <ipc_find_env>:
// Find the first environment of the given type.  We'll use this to
// find special environments.
// Returns 0 if no such environment exists.
envid_t
ipc_find_env(enum EnvType type)
{
  8028fd:	f3 0f 1e fb          	endbr32 
  802901:	55                   	push   %ebp
  802902:	89 e5                	mov    %esp,%ebp
  802904:	8b 4d 08             	mov    0x8(%ebp),%ecx
	int i;
	for (i = 0; i < NENV; i++)
  802907:	b8 00 00 00 00       	mov    $0x0,%eax
		if (envs[i].env_type == type)
  80290c:	6b d0 7c             	imul   $0x7c,%eax,%edx
  80290f:	81 c2 00 00 c0 ee    	add    $0xeec00000,%edx
  802915:	8b 52 50             	mov    0x50(%edx),%edx
  802918:	39 ca                	cmp    %ecx,%edx
  80291a:	74 11                	je     80292d <ipc_find_env+0x30>
	for (i = 0; i < NENV; i++)
  80291c:	83 c0 01             	add    $0x1,%eax
  80291f:	3d 00 04 00 00       	cmp    $0x400,%eax
  802924:	75 e6                	jne    80290c <ipc_find_env+0xf>
			return envs[i].env_id;
	return 0;
  802926:	b8 00 00 00 00       	mov    $0x0,%eax
  80292b:	eb 0b                	jmp    802938 <ipc_find_env+0x3b>
			return envs[i].env_id;
  80292d:	6b c0 7c             	imul   $0x7c,%eax,%eax
  802930:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  802935:	8b 40 48             	mov    0x48(%eax),%eax
}
  802938:	5d                   	pop    %ebp
  802939:	c3                   	ret    

0080293a <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  80293a:	f3 0f 1e fb          	endbr32 
  80293e:	55                   	push   %ebp
  80293f:	89 e5                	mov    %esp,%ebp
  802941:	8b 45 08             	mov    0x8(%ebp),%eax
	pte_t pte;

	if (!(uvpd[PDX(v)] & PTE_P))
  802944:	89 c2                	mov    %eax,%edx
  802946:	c1 ea 16             	shr    $0x16,%edx
  802949:	8b 0c 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%ecx
		return 0;
  802950:	ba 00 00 00 00       	mov    $0x0,%edx
	if (!(uvpd[PDX(v)] & PTE_P))
  802955:	f6 c1 01             	test   $0x1,%cl
  802958:	74 1c                	je     802976 <pageref+0x3c>
	pte = uvpt[PGNUM(v)];
  80295a:	c1 e8 0c             	shr    $0xc,%eax
  80295d:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  802964:	a8 01                	test   $0x1,%al
  802966:	74 0e                	je     802976 <pageref+0x3c>
		return 0;
	return pages[PGNUM(pte)].pp_ref;
  802968:	c1 e8 0c             	shr    $0xc,%eax
  80296b:	0f b7 14 c5 04 00 00 	movzwl -0x10fffffc(,%eax,8),%edx
  802972:	ef 
  802973:	0f b7 d2             	movzwl %dx,%edx
}
  802976:	89 d0                	mov    %edx,%eax
  802978:	5d                   	pop    %ebp
  802979:	c3                   	ret    
  80297a:	66 90                	xchg   %ax,%ax
  80297c:	66 90                	xchg   %ax,%ax
  80297e:	66 90                	xchg   %ax,%ax

00802980 <__udivdi3>:
  802980:	f3 0f 1e fb          	endbr32 
  802984:	55                   	push   %ebp
  802985:	57                   	push   %edi
  802986:	56                   	push   %esi
  802987:	53                   	push   %ebx
  802988:	83 ec 1c             	sub    $0x1c,%esp
  80298b:	8b 54 24 3c          	mov    0x3c(%esp),%edx
  80298f:	8b 6c 24 30          	mov    0x30(%esp),%ebp
  802993:	8b 74 24 34          	mov    0x34(%esp),%esi
  802997:	8b 5c 24 38          	mov    0x38(%esp),%ebx
  80299b:	85 d2                	test   %edx,%edx
  80299d:	75 19                	jne    8029b8 <__udivdi3+0x38>
  80299f:	39 f3                	cmp    %esi,%ebx
  8029a1:	76 4d                	jbe    8029f0 <__udivdi3+0x70>
  8029a3:	31 ff                	xor    %edi,%edi
  8029a5:	89 e8                	mov    %ebp,%eax
  8029a7:	89 f2                	mov    %esi,%edx
  8029a9:	f7 f3                	div    %ebx
  8029ab:	89 fa                	mov    %edi,%edx
  8029ad:	83 c4 1c             	add    $0x1c,%esp
  8029b0:	5b                   	pop    %ebx
  8029b1:	5e                   	pop    %esi
  8029b2:	5f                   	pop    %edi
  8029b3:	5d                   	pop    %ebp
  8029b4:	c3                   	ret    
  8029b5:	8d 76 00             	lea    0x0(%esi),%esi
  8029b8:	39 f2                	cmp    %esi,%edx
  8029ba:	76 14                	jbe    8029d0 <__udivdi3+0x50>
  8029bc:	31 ff                	xor    %edi,%edi
  8029be:	31 c0                	xor    %eax,%eax
  8029c0:	89 fa                	mov    %edi,%edx
  8029c2:	83 c4 1c             	add    $0x1c,%esp
  8029c5:	5b                   	pop    %ebx
  8029c6:	5e                   	pop    %esi
  8029c7:	5f                   	pop    %edi
  8029c8:	5d                   	pop    %ebp
  8029c9:	c3                   	ret    
  8029ca:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  8029d0:	0f bd fa             	bsr    %edx,%edi
  8029d3:	83 f7 1f             	xor    $0x1f,%edi
  8029d6:	75 48                	jne    802a20 <__udivdi3+0xa0>
  8029d8:	39 f2                	cmp    %esi,%edx
  8029da:	72 06                	jb     8029e2 <__udivdi3+0x62>
  8029dc:	31 c0                	xor    %eax,%eax
  8029de:	39 eb                	cmp    %ebp,%ebx
  8029e0:	77 de                	ja     8029c0 <__udivdi3+0x40>
  8029e2:	b8 01 00 00 00       	mov    $0x1,%eax
  8029e7:	eb d7                	jmp    8029c0 <__udivdi3+0x40>
  8029e9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  8029f0:	89 d9                	mov    %ebx,%ecx
  8029f2:	85 db                	test   %ebx,%ebx
  8029f4:	75 0b                	jne    802a01 <__udivdi3+0x81>
  8029f6:	b8 01 00 00 00       	mov    $0x1,%eax
  8029fb:	31 d2                	xor    %edx,%edx
  8029fd:	f7 f3                	div    %ebx
  8029ff:	89 c1                	mov    %eax,%ecx
  802a01:	31 d2                	xor    %edx,%edx
  802a03:	89 f0                	mov    %esi,%eax
  802a05:	f7 f1                	div    %ecx
  802a07:	89 c6                	mov    %eax,%esi
  802a09:	89 e8                	mov    %ebp,%eax
  802a0b:	89 f7                	mov    %esi,%edi
  802a0d:	f7 f1                	div    %ecx
  802a0f:	89 fa                	mov    %edi,%edx
  802a11:	83 c4 1c             	add    $0x1c,%esp
  802a14:	5b                   	pop    %ebx
  802a15:	5e                   	pop    %esi
  802a16:	5f                   	pop    %edi
  802a17:	5d                   	pop    %ebp
  802a18:	c3                   	ret    
  802a19:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  802a20:	89 f9                	mov    %edi,%ecx
  802a22:	b8 20 00 00 00       	mov    $0x20,%eax
  802a27:	29 f8                	sub    %edi,%eax
  802a29:	d3 e2                	shl    %cl,%edx
  802a2b:	89 54 24 08          	mov    %edx,0x8(%esp)
  802a2f:	89 c1                	mov    %eax,%ecx
  802a31:	89 da                	mov    %ebx,%edx
  802a33:	d3 ea                	shr    %cl,%edx
  802a35:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  802a39:	09 d1                	or     %edx,%ecx
  802a3b:	89 f2                	mov    %esi,%edx
  802a3d:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  802a41:	89 f9                	mov    %edi,%ecx
  802a43:	d3 e3                	shl    %cl,%ebx
  802a45:	89 c1                	mov    %eax,%ecx
  802a47:	d3 ea                	shr    %cl,%edx
  802a49:	89 f9                	mov    %edi,%ecx
  802a4b:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  802a4f:	89 eb                	mov    %ebp,%ebx
  802a51:	d3 e6                	shl    %cl,%esi
  802a53:	89 c1                	mov    %eax,%ecx
  802a55:	d3 eb                	shr    %cl,%ebx
  802a57:	09 de                	or     %ebx,%esi
  802a59:	89 f0                	mov    %esi,%eax
  802a5b:	f7 74 24 08          	divl   0x8(%esp)
  802a5f:	89 d6                	mov    %edx,%esi
  802a61:	89 c3                	mov    %eax,%ebx
  802a63:	f7 64 24 0c          	mull   0xc(%esp)
  802a67:	39 d6                	cmp    %edx,%esi
  802a69:	72 15                	jb     802a80 <__udivdi3+0x100>
  802a6b:	89 f9                	mov    %edi,%ecx
  802a6d:	d3 e5                	shl    %cl,%ebp
  802a6f:	39 c5                	cmp    %eax,%ebp
  802a71:	73 04                	jae    802a77 <__udivdi3+0xf7>
  802a73:	39 d6                	cmp    %edx,%esi
  802a75:	74 09                	je     802a80 <__udivdi3+0x100>
  802a77:	89 d8                	mov    %ebx,%eax
  802a79:	31 ff                	xor    %edi,%edi
  802a7b:	e9 40 ff ff ff       	jmp    8029c0 <__udivdi3+0x40>
  802a80:	8d 43 ff             	lea    -0x1(%ebx),%eax
  802a83:	31 ff                	xor    %edi,%edi
  802a85:	e9 36 ff ff ff       	jmp    8029c0 <__udivdi3+0x40>
  802a8a:	66 90                	xchg   %ax,%ax
  802a8c:	66 90                	xchg   %ax,%ax
  802a8e:	66 90                	xchg   %ax,%ax

00802a90 <__umoddi3>:
  802a90:	f3 0f 1e fb          	endbr32 
  802a94:	55                   	push   %ebp
  802a95:	57                   	push   %edi
  802a96:	56                   	push   %esi
  802a97:	53                   	push   %ebx
  802a98:	83 ec 1c             	sub    $0x1c,%esp
  802a9b:	8b 44 24 3c          	mov    0x3c(%esp),%eax
  802a9f:	8b 74 24 30          	mov    0x30(%esp),%esi
  802aa3:	8b 5c 24 34          	mov    0x34(%esp),%ebx
  802aa7:	8b 7c 24 38          	mov    0x38(%esp),%edi
  802aab:	85 c0                	test   %eax,%eax
  802aad:	75 19                	jne    802ac8 <__umoddi3+0x38>
  802aaf:	39 df                	cmp    %ebx,%edi
  802ab1:	76 5d                	jbe    802b10 <__umoddi3+0x80>
  802ab3:	89 f0                	mov    %esi,%eax
  802ab5:	89 da                	mov    %ebx,%edx
  802ab7:	f7 f7                	div    %edi
  802ab9:	89 d0                	mov    %edx,%eax
  802abb:	31 d2                	xor    %edx,%edx
  802abd:	83 c4 1c             	add    $0x1c,%esp
  802ac0:	5b                   	pop    %ebx
  802ac1:	5e                   	pop    %esi
  802ac2:	5f                   	pop    %edi
  802ac3:	5d                   	pop    %ebp
  802ac4:	c3                   	ret    
  802ac5:	8d 76 00             	lea    0x0(%esi),%esi
  802ac8:	89 f2                	mov    %esi,%edx
  802aca:	39 d8                	cmp    %ebx,%eax
  802acc:	76 12                	jbe    802ae0 <__umoddi3+0x50>
  802ace:	89 f0                	mov    %esi,%eax
  802ad0:	89 da                	mov    %ebx,%edx
  802ad2:	83 c4 1c             	add    $0x1c,%esp
  802ad5:	5b                   	pop    %ebx
  802ad6:	5e                   	pop    %esi
  802ad7:	5f                   	pop    %edi
  802ad8:	5d                   	pop    %ebp
  802ad9:	c3                   	ret    
  802ada:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  802ae0:	0f bd e8             	bsr    %eax,%ebp
  802ae3:	83 f5 1f             	xor    $0x1f,%ebp
  802ae6:	75 50                	jne    802b38 <__umoddi3+0xa8>
  802ae8:	39 d8                	cmp    %ebx,%eax
  802aea:	0f 82 e0 00 00 00    	jb     802bd0 <__umoddi3+0x140>
  802af0:	89 d9                	mov    %ebx,%ecx
  802af2:	39 f7                	cmp    %esi,%edi
  802af4:	0f 86 d6 00 00 00    	jbe    802bd0 <__umoddi3+0x140>
  802afa:	89 d0                	mov    %edx,%eax
  802afc:	89 ca                	mov    %ecx,%edx
  802afe:	83 c4 1c             	add    $0x1c,%esp
  802b01:	5b                   	pop    %ebx
  802b02:	5e                   	pop    %esi
  802b03:	5f                   	pop    %edi
  802b04:	5d                   	pop    %ebp
  802b05:	c3                   	ret    
  802b06:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  802b0d:	8d 76 00             	lea    0x0(%esi),%esi
  802b10:	89 fd                	mov    %edi,%ebp
  802b12:	85 ff                	test   %edi,%edi
  802b14:	75 0b                	jne    802b21 <__umoddi3+0x91>
  802b16:	b8 01 00 00 00       	mov    $0x1,%eax
  802b1b:	31 d2                	xor    %edx,%edx
  802b1d:	f7 f7                	div    %edi
  802b1f:	89 c5                	mov    %eax,%ebp
  802b21:	89 d8                	mov    %ebx,%eax
  802b23:	31 d2                	xor    %edx,%edx
  802b25:	f7 f5                	div    %ebp
  802b27:	89 f0                	mov    %esi,%eax
  802b29:	f7 f5                	div    %ebp
  802b2b:	89 d0                	mov    %edx,%eax
  802b2d:	31 d2                	xor    %edx,%edx
  802b2f:	eb 8c                	jmp    802abd <__umoddi3+0x2d>
  802b31:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  802b38:	89 e9                	mov    %ebp,%ecx
  802b3a:	ba 20 00 00 00       	mov    $0x20,%edx
  802b3f:	29 ea                	sub    %ebp,%edx
  802b41:	d3 e0                	shl    %cl,%eax
  802b43:	89 44 24 08          	mov    %eax,0x8(%esp)
  802b47:	89 d1                	mov    %edx,%ecx
  802b49:	89 f8                	mov    %edi,%eax
  802b4b:	d3 e8                	shr    %cl,%eax
  802b4d:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  802b51:	89 54 24 04          	mov    %edx,0x4(%esp)
  802b55:	8b 54 24 04          	mov    0x4(%esp),%edx
  802b59:	09 c1                	or     %eax,%ecx
  802b5b:	89 d8                	mov    %ebx,%eax
  802b5d:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  802b61:	89 e9                	mov    %ebp,%ecx
  802b63:	d3 e7                	shl    %cl,%edi
  802b65:	89 d1                	mov    %edx,%ecx
  802b67:	d3 e8                	shr    %cl,%eax
  802b69:	89 e9                	mov    %ebp,%ecx
  802b6b:	89 7c 24 0c          	mov    %edi,0xc(%esp)
  802b6f:	d3 e3                	shl    %cl,%ebx
  802b71:	89 c7                	mov    %eax,%edi
  802b73:	89 d1                	mov    %edx,%ecx
  802b75:	89 f0                	mov    %esi,%eax
  802b77:	d3 e8                	shr    %cl,%eax
  802b79:	89 e9                	mov    %ebp,%ecx
  802b7b:	89 fa                	mov    %edi,%edx
  802b7d:	d3 e6                	shl    %cl,%esi
  802b7f:	09 d8                	or     %ebx,%eax
  802b81:	f7 74 24 08          	divl   0x8(%esp)
  802b85:	89 d1                	mov    %edx,%ecx
  802b87:	89 f3                	mov    %esi,%ebx
  802b89:	f7 64 24 0c          	mull   0xc(%esp)
  802b8d:	89 c6                	mov    %eax,%esi
  802b8f:	89 d7                	mov    %edx,%edi
  802b91:	39 d1                	cmp    %edx,%ecx
  802b93:	72 06                	jb     802b9b <__umoddi3+0x10b>
  802b95:	75 10                	jne    802ba7 <__umoddi3+0x117>
  802b97:	39 c3                	cmp    %eax,%ebx
  802b99:	73 0c                	jae    802ba7 <__umoddi3+0x117>
  802b9b:	2b 44 24 0c          	sub    0xc(%esp),%eax
  802b9f:	1b 54 24 08          	sbb    0x8(%esp),%edx
  802ba3:	89 d7                	mov    %edx,%edi
  802ba5:	89 c6                	mov    %eax,%esi
  802ba7:	89 ca                	mov    %ecx,%edx
  802ba9:	0f b6 4c 24 04       	movzbl 0x4(%esp),%ecx
  802bae:	29 f3                	sub    %esi,%ebx
  802bb0:	19 fa                	sbb    %edi,%edx
  802bb2:	89 d0                	mov    %edx,%eax
  802bb4:	d3 e0                	shl    %cl,%eax
  802bb6:	89 e9                	mov    %ebp,%ecx
  802bb8:	d3 eb                	shr    %cl,%ebx
  802bba:	d3 ea                	shr    %cl,%edx
  802bbc:	09 d8                	or     %ebx,%eax
  802bbe:	83 c4 1c             	add    $0x1c,%esp
  802bc1:	5b                   	pop    %ebx
  802bc2:	5e                   	pop    %esi
  802bc3:	5f                   	pop    %edi
  802bc4:	5d                   	pop    %ebp
  802bc5:	c3                   	ret    
  802bc6:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  802bcd:	8d 76 00             	lea    0x0(%esi),%esi
  802bd0:	29 fe                	sub    %edi,%esi
  802bd2:	19 c3                	sbb    %eax,%ebx
  802bd4:	89 f2                	mov    %esi,%edx
  802bd6:	89 d9                	mov    %ebx,%ecx
  802bd8:	e9 1d ff ff ff       	jmp    802afa <__umoddi3+0x6a>
